Skip to content

Commit 740b54d

Browse files
committed
Php8.5 Deprecates Use of Null as Array Index
1 parent fd26e45 commit 740b54d

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ private function processTokenStack(false|array $tokens, ?string $cellID = null,
16991699
return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e);
17001700
}
17011701
}
1702-
} elseif (!is_numeric($token) && !is_object($token) && isset(self::BINARY_OPERATORS[$token])) {
1702+
} elseif (!is_numeric($token) && !is_object($token) && isset($token, self::BINARY_OPERATORS[$token])) {
17031703
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
17041704
// We must have two operands, error if we don't
17051705
$operand2Data = $stack->pop();

src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ protected static function getFilteredColumn(array $database, ?int $field, array
117117
/** @var mixed[] $row */
118118
foreach ($database as $rowKey => $row) {
119119
$keys = array_keys($row);
120-
$key = $keys[$field] ?? null;
120+
$key = ($field === null) ? null : ($keys[$field] ?? null);
121121
$columnKey = $key ?? 'A';
122-
$columnData[$rowKey][$columnKey] = $row[$key] ?? $defaultReturnColumnValue;
122+
$columnData[$rowKey][$columnKey] = ($key === null) ? $defaultReturnColumnValue : ($row[$key] ?? $defaultReturnColumnValue);
123123
}
124124

125125
return $columnData;

src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function initialiseForLoop(): void
7878

7979
private function initialiseCondition(): void
8080
{
81-
if (isset($this->conditionMap[$this->pendingStoreKey]) && $this->conditionMap[$this->pendingStoreKey]) {
81+
if (isset($this->pendingStoreKey, $this->conditionMap[$this->pendingStoreKey]) && $this->conditionMap[$this->pendingStoreKey]) {
8282
$this->currentCondition = $this->pendingStoreKey;
8383
$stackDepth = count($this->storeKeysStack);
8484
if ($stackDepth > 1) {
@@ -90,7 +90,7 @@ private function initialiseCondition(): void
9090

9191
private function initialiseThen(): void
9292
{
93-
if (isset($this->thenMap[$this->pendingStoreKey]) && $this->thenMap[$this->pendingStoreKey]) {
93+
if (isset($this->pendingStoreKey, $this->thenMap[$this->pendingStoreKey]) && $this->thenMap[$this->pendingStoreKey]) {
9494
$this->currentOnlyIf = $this->pendingStoreKey;
9595
} elseif (
9696
isset($this->previousStoreKey, $this->thenMap[$this->previousStoreKey])
@@ -102,7 +102,7 @@ private function initialiseThen(): void
102102

103103
private function initialiseElse(): void
104104
{
105-
if (isset($this->elseMap[$this->pendingStoreKey]) && $this->elseMap[$this->pendingStoreKey]) {
105+
if (isset($this->pendingStoreKey, $this->elseMap[$this->pendingStoreKey]) && $this->elseMap[$this->pendingStoreKey]) {
106106
$this->currentOnlyIfNot = $this->pendingStoreKey;
107107
} elseif (
108108
isset($this->previousStoreKey, $this->elseMap[$this->previousStoreKey])

src/PhpSpreadsheet/Reader/Xlsx.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
12771277
// Set comment properties
12781278
$comment = $docSheet->getComment([(int) $column + 1, (int) $row + 1]);
12791279
$comment->getFillColor()->setRGB($fillColor);
1280-
if (isset($drowingImages[$fillImageRelId])) {
1280+
if (isset($fillImageRelId, $drowingImages[$fillImageRelId])) {
12811281
$objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
12821282
$objDrawing->setName($fillImageTitle);
12831283
$imagePath = str_replace(['../', '/xl/'], 'xl/', $drowingImages[$fillImageRelId]);

src/PhpSpreadsheet/Writer/Pdf/Dompdf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function save($filename, int $flags = 0): void
7676
public function specialErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
7777
{
7878
if ($errno === E_DEPRECATED) {
79-
if (preg_match('/canonical|imagedestroy|http_get_last_response_headers/', $errstr) === 1) {
79+
if (preg_match('/canonical|imagedestroy|http_get_last_response_headers|Using null as an array offset/', $errstr) === 1) {
8080
return true;
8181
}
8282
}

src/PhpSpreadsheet/Writer/Xlsx/Rels.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\
219219
// (! synchronize with \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::writeDrawings)
220220
reset($drawingOriginalIds);
221221
$relPath = key($drawingOriginalIds);
222-
if (isset($drawingOriginalIds[$relPath])) {
222+
if (isset($relPath, $drawingOriginalIds[$relPath])) {
223223
$rId = (int) (substr($drawingOriginalIds[$relPath], 3));
224224
}
225225

0 commit comments

Comments
 (0)