diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index f5790a1de6..1cefa64145 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2861,7 +2861,8 @@ public function clearCalculationCacheForWorksheet($worksheetName): void */ public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void { - if (isset($this->calculationCache[$fromWorksheetName])) { + // PHP 8.5: avoid using null as an array offset, coerce to empty string instead + if (isset($this->calculationCache[$fromWorksheetName ?? ''])) { $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; unset($this->calculationCache[$fromWorksheetName]); } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php index 4134b2f184..db57248170 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php @@ -137,8 +137,9 @@ private function readColumnAttributes(SimpleXMLElement $worksheetCols, $readData foreach ($worksheetCols->col as $column) { $startColumn = Coordinate::stringFromColumnIndex((int) $column['min']); $endColumn = Coordinate::stringFromColumnIndex((int) $column['max']); - ++$endColumn; - for ($columnAddress = $startColumn; $columnAddress !== $endColumn; ++$columnAddress) { + // PHP 8.5: avoid increment on non-numeric string, use column helper instead + $endColumn = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($endColumn) + 1); + for ($columnAddress = $startColumn; $columnAddress !== $endColumn; $columnAddress = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($columnAddress) + 1)) { $columnAttributes[$columnAddress] = $this->readColumnRangeAttributes($column, $readDataOnly); if ((int) ($column['max']) == 16384) { diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 19833b71e5..e2e43cbbea 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -2503,14 +2503,16 @@ public function rangeToArray($pRange, $nullValue = null, $calculateFormulas = tr $maxCol = Coordinate::stringFromColumnIndex($rangeEnd[0]); $maxRow = $rangeEnd[1]; - ++$maxCol; + // PHP 8.5: avoid increment on non-numeric string, use column helper instead + $maxCol = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($maxCol) + 1); // Loop through rows $r = -1; for ($row = $minRow; $row <= $maxRow; ++$row) { $rRef = $returnCellRef ? $row : ++$r; $c = -1; // Loop through columns in the current row - for ($col = $minCol; $col != $maxCol; ++$col) { + // PHP 8.5: avoid increment on non-numeric string, use column helper instead + for ($col = $minCol; $col != $maxCol; $col = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($col) + 1)) { $cRef = $returnCellRef ? $col : ++$c; // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen // so we test and retrieve directly against cellCollection