Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Looming Problems with PHP8.1 #2231

Merged
merged 3 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Worksheet/ColumnIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Worksheet/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Worksheet/RowCellIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Worksheet/RowIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 3 additions & 8 deletions tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}