diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 42b9fe706..e7c917ec7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1175,11 +1175,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Cell/Coordinate.php - - - message: "#^Cannot use array destructuring on array\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Cell/Coordinate.php - - message: "#^Parameter \\#4 \\$currentRow of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:validateRange\\(\\) expects int, string given\\.$#" count: 1 @@ -3120,11 +3115,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Reader/Xml/Style.php - - - message: "#^Cannot use array destructuring on array\\|null\\.$#" - count: 4 - path: src/PhpSpreadsheet/ReferenceHelper.php - - message: "#^Elseif condition is always true\\.$#" count: 1 diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 703eac08b..ea53919cb 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -383,7 +383,7 @@ abstract class Coordinate // Sort the result by column and row $sortKeys = []; foreach ($cellList as $coord) { - [$column, $row] = sscanf($coord, '%[A-Z]%d'); + sscanf($coord, '%[A-Z]%d', $column, $row); $sortKeys[sprintf('%3s%09d', $column, $row)] = $coord; } ksort($sortKeys); diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index a29bdb59f..d49f54577 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\Collection; use Generator; use PhpOffice\PhpSpreadsheet\Cell\Cell; -use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; @@ -152,8 +151,6 @@ class Cells { $sortKeys = []; foreach ($this->getCoordinates() as $coord) { - $column = ''; - $row = 0; sscanf($coord, '%[A-Z]%d', $column, $row); $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord; } @@ -172,8 +169,6 @@ class Cells // Lookup highest column and highest row $col = ['A' => '1A']; $row = [1]; - $c = ''; - $r = 0; foreach ($this->getCoordinates() as $coord) { sscanf($coord, '%[A-Z]%d', $c, $r); $row[$r] = $r; @@ -207,9 +202,6 @@ class Cells */ public function getCurrentColumn() { - $column = ''; - $row = 0; - sscanf($this->currentCoordinate ?? '', '%[A-Z]%d', $column, $row); return $column; @@ -222,9 +214,6 @@ class Cells */ public function getCurrentRow() { - $column = ''; - $row = 0; - sscanf($this->currentCoordinate ?? '', '%[A-Z]%d', $column, $row); return (int) $row; @@ -245,8 +234,6 @@ class Cells } $maxColumn = '1A'; - $c = ''; - $r = 0; foreach ($this->getCoordinates() as $coord) { sscanf($coord, '%[A-Z]%d', $c, $r); if ($r != $row) { @@ -273,8 +260,6 @@ class Cells } $maxRow = 1; - $c = ''; - $r = 0; foreach ($this->getCoordinates() as $coord) { sscanf($coord, '%[A-Z]%d', $c, $r); if ($c != $column) { @@ -341,8 +326,6 @@ class Cells */ public function removeRow($row): void { - $c = ''; - $r = 0; foreach ($this->getCoordinates() as $coord) { sscanf($coord, '%[A-Z]%d', $c, $r); if ($r == $row) { @@ -358,8 +341,6 @@ class Cells */ public function removeColumn($column): void { - $c = ''; - $r = 0; foreach ($this->getCoordinates() as $coord) { sscanf($coord, '%[A-Z]%d', $c, $r); if ($c == $column) { diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 665b2e182..c5f57792c 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -90,8 +90,8 @@ class ReferenceHelper */ public static function cellSort($a, $b) { - [$ac, $ar] = sscanf($a, '%[A-Z]%d'); - [$bc, $br] = sscanf($b, '%[A-Z]%d'); + sscanf($a, '%[A-Z]%d', $ac, $ar); + sscanf($b, '%[A-Z]%d', $bc, $br); if ($ar === $br) { return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); @@ -111,8 +111,8 @@ class ReferenceHelper */ public static function cellReverseSort($a, $b) { - [$ac, $ar] = sscanf($a, '%[A-Z]%d'); - [$bc, $br] = sscanf($b, '%[A-Z]%d'); + sscanf($a, '%[A-Z]%d', $ac, $ar); + sscanf($b, '%[A-Z]%d', $bc, $br); if ($ar === $br) { return -strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);