diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a12fd2f507..49dd41a47e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6575,16 +6575,6 @@ parameters: count: 3 path: tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php - - - message: "#^Parameter \\#2 \\$locale of function setlocale expects string\\|null, string\\|false given\\.$#" - count: 1 - path: tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php - - - - message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|false given\\.$#" - count: 1 - path: tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php - - message: "#^Cannot call method getDrawingCollection\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#" count: 4 diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 0d771ff77c..e6b79c7a14 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -4368,7 +4368,7 @@ private static function dataTestReference(&$operandData) $rowKey = array_shift($rKeys); $cKeys = array_keys(array_keys($operand[$rowKey])); $colKey = array_shift($cKeys); - if (ctype_upper($colKey)) { + if (ctype_upper("$colKey")) { $operandData['reference'] = $colKey . $rowKey; } } diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index 0651a7a458..179e9f27bb 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -131,10 +131,8 @@ public function rewind(): void /** * Return the current column in this worksheet. - * - * @return Column */ - public function current() + public function current(): Column { return new Column($this->worksheet, Coordinate::stringFromColumnIndex($this->currentColumnIndex)); } diff --git a/src/PhpSpreadsheet/Worksheet/Iterator.php b/src/PhpSpreadsheet/Worksheet/Iterator.php index 134b619a68..a4061b787e 100644 --- a/src/PhpSpreadsheet/Worksheet/Iterator.php +++ b/src/PhpSpreadsheet/Worksheet/Iterator.php @@ -63,10 +63,8 @@ public function next(): void /** * Are there more Worksheet instances available? - * - * @return bool */ - public function valid() + public function valid(): bool { return $this->position < $this->subject->getSheetCount() && $this->position >= 0; } diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 6a96a826a5..fc04ccd313 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -153,10 +153,8 @@ public function prev(): void /** * Indicate if more columns exist in the worksheet range of columns that we're iterating. - * - * @return bool */ - public function valid() + public function valid(): bool { return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex; } diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 7d49f1acde..7fe0f80b3d 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -115,10 +115,8 @@ public function rewind(): void /** * Return the current row in this worksheet. - * - * @return Row */ - public function current() + public function current(): Row { return new Row($this->subject, $this->position); } diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php index 3a9fb1cc6c..13a13bc98e 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -31,7 +31,7 @@ protected function setUp(): void protected function tearDown(): void { - if ($this->localeAdjusted) { + if ($this->localeAdjusted && is_string($this->currentLocale)) { setlocale(LC_ALL, $this->currentLocale); } } @@ -55,12 +55,7 @@ public function testLocaleFloatsCorrectlyConvertedByWriter(): void $result = $spreadsheet->getActiveSheet()->getCell('A1')->getValue(); - ob_start(); - var_dump($result); - preg_match('/(?:double|float)\(([^\)]+)\)/mui', ob_get_clean(), $matches); - self::assertArrayHasKey(1, $matches); - $actual = $matches[1]; - // From PHP8, https://wiki.php.net/rfc/locale_independent_float_to_string applies - self::assertEquals('1,1', $actual); + $actual = sprintf('%f', $result); + self::assertStringContainsString('1,1', $actual); } }