Prep Work Before Upgrading to Phpstan 1.7.7 (#2867)

Clean up the usual discrepancies which arise between Phpstan releases.
This commit is contained in:
oleibman 2022-06-01 21:10:41 -07:00 committed by GitHub
parent c936f1d9f8
commit 8bb568c9ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 55 deletions

View File

@ -95,11 +95,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
-
message: "#^Offset 'type' does not exist on array\\|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Offset 'value' does not exist on array\\|null\\.$#" message: "#^Offset 'value' does not exist on array\\|null\\.$#"
count: 5 count: 5
@ -765,11 +760,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php path: src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php
-
message: "#^PHPDoc tag @var for constant PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\MathTrig\\\\Subtotal\\:\\:CALL_FUNCTIONS with type array\\<callable\\(\\)\\: mixed\\> is not subtype of value array\\{1\\: array\\{'PhpOffice…', 'average'\\}, 2\\: array\\{'PhpOffice…', 'COUNT'\\}, 3\\: array\\{'PhpOffice…', 'COUNTA'\\}, 4\\: array\\{'PhpOffice…', 'max'\\}, 5\\: array\\{'PhpOffice…', 'min'\\}, 6\\: array\\{'PhpOffice…', 'product'\\}, 7\\: array\\{'PhpOffice…', 'STDEV'\\}, 8\\: array\\{'PhpOffice…', 'STDEVP'\\}, \\.\\.\\.\\}\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\:\\:MAXIFS\\(\\) should return float but returns float\\|string\\|null\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\:\\:MAXIFS\\(\\) should return float but returns float\\|string\\|null\\.$#"
count: 1 count: 1
@ -4300,21 +4290,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Parser.php path: src/PhpSpreadsheet/Writer/Xls/Parser.php
-
message: "#^Offset 'left' does not exist on non\\-empty\\-array\\|string\\.$#"
count: 6
path: src/PhpSpreadsheet/Writer/Xls/Parser.php
-
message: "#^Offset 'right' does not exist on non\\-empty\\-array\\|string\\.$#"
count: 5
path: src/PhpSpreadsheet/Writer/Xls/Parser.php
-
message: "#^Offset 'value' does not exist on non\\-empty\\-array\\|string\\.$#"
count: 7
path: src/PhpSpreadsheet/Writer/Xls/Parser.php
- -
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Parser\\:\\:\\$spreadsheet has no type specified\\.$#" message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Parser\\:\\:\\$spreadsheet has no type specified\\.$#"
count: 1 count: 1
@ -4815,11 +4790,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
- -
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#" message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#"
count: 1 count: 1
@ -4860,8 +4830,3 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Strict comparison using \\=\\=\\= between false and true will always evaluate to false\\.$#"
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

View File

@ -24,3 +24,8 @@ parameters:
- '~^Instantiated class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot) not found\.$~' - '~^Instantiated class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot) not found\.$~'
- '~^Call to method .*\(\) on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~' - '~^Call to method .*\(\) on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~'
- '~^Access to property .* on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~' - '~^Access to property .* on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~'
# Some issues in Xls/Parser between 1.6.3 and 1.7.7
-
message: "#^Offset '(left|right|value)' does not exist on (non-empty-array\\|string|array\\|null)\\.$#"
path: src/PhpSpreadsheet/Writer/Xls/Parser.php

View File

@ -4021,6 +4021,7 @@ class Calculation
// Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand
$isOperandOrFunction = (bool) preg_match($regexpMatchString, substr($formula, $index), $match); $isOperandOrFunction = (bool) preg_match($regexpMatchString, substr($formula, $index), $match);
$expectingOperatorCopy = $expectingOperator;
if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?
// Put a negation on the stack // Put a negation on the stack
$stack->push('Unary Operator', '~'); $stack->push('Unary Operator', '~');
@ -4173,7 +4174,7 @@ class Calculation
$this->branchPruner->incrementDepth(); $this->branchPruner->incrementDepth();
$stack->push('Brace', '(', null); $stack->push('Brace', '(', null);
++$index; ++$index;
} elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number? } elseif ($isOperandOrFunction && !$expectingOperatorCopy) { // do we now have a function/variable/number?
$expectingOperator = true; $expectingOperator = true;
$expectingOperand = false; $expectingOperand = false;
$val = $match[1]; $val = $match[1];
@ -4398,13 +4399,17 @@ class Calculation
// If we're expecting an operator, but only have a space between the previous and next operands (and both are // If we're expecting an operator, but only have a space between the previous and next operands (and both are
// Cell References) then we have an INTERSECTION operator // Cell References) then we have an INTERSECTION operator
$countOutputMinus1 = count($output) - 1;
if ( if (
($expectingOperator) && ($expectingOperator) &&
array_key_exists($countOutputMinus1, $output) &&
is_array($output[$countOutputMinus1]) &&
array_key_exists('type', $output[$countOutputMinus1]) &&
( (
(preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) &&
($output[count($output) - 1]['type'] === 'Cell Reference') || ($output[$countOutputMinus1]['type'] === 'Cell Reference') ||
(preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '.*/miu', substr($formula, $index), $match)) && (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '.*/miu', substr($formula, $index), $match)) &&
($output[count($output) - 1]['type'] === 'Defined Name' || $output[count($output) - 1]['type'] === 'Value') ($output[$countOutputMinus1]['type'] === 'Defined Name' || $output[$countOutputMinus1]['type'] === 'Value')
) )
) { ) {
while ( while (

View File

@ -54,7 +54,6 @@ class Subtotal
); );
} }
/** @var callable[] */
private const CALL_FUNCTIONS = [ private const CALL_FUNCTIONS = [
1 => [Statistical\Averages::class, 'average'], // 1 and 101 1 => [Statistical\Averages::class, 'average'], // 1 and 101
[Statistical\Counts::class, 'COUNT'], // 2 and 102 [Statistical\Counts::class, 'COUNT'], // 2 and 102

View File

@ -2280,13 +2280,15 @@ class Xls extends BaseReader
// bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right // bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right
$diagonalUp = (0x80000000 & self::getInt4d($recordData, 10)) >> 31 ? true : false; $diagonalUp = (0x80000000 & self::getInt4d($recordData, 10)) >> 31 ? true : false;
if ($diagonalUp == false && $diagonalDown == false) { if ($diagonalUp === false) {
if ($diagonalDown == false) {
$objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_NONE); $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_NONE);
} elseif ($diagonalUp == true && $diagonalDown == false) { } else {
$objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_UP);
} elseif ($diagonalUp == false && $diagonalDown == true) {
$objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_DOWN); $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_DOWN);
} elseif ($diagonalUp == true && $diagonalDown == true) { }
} elseif ($diagonalDown == false) {
$objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_UP);
} else {
$objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_BOTH); $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_BOTH);
} }

View File

@ -194,12 +194,14 @@ class Styles extends BaseParserClass
$diagonalUp = self::boolean($diagonalUp); $diagonalUp = self::boolean($diagonalUp);
$diagonalDown = $this->getAttribute($borderStyleXml, 'diagonalDown'); $diagonalDown = $this->getAttribute($borderStyleXml, 'diagonalDown');
$diagonalDown = self::boolean($diagonalDown); $diagonalDown = self::boolean($diagonalDown);
if (!$diagonalUp && !$diagonalDown) { if ($diagonalUp === false) {
if ($diagonalDown === false) {
$borderStyle->setDiagonalDirection(Borders::DIAGONAL_NONE); $borderStyle->setDiagonalDirection(Borders::DIAGONAL_NONE);
} elseif ($diagonalUp && !$diagonalDown) { } else {
$borderStyle->setDiagonalDirection(Borders::DIAGONAL_UP);
} elseif (!$diagonalUp && $diagonalDown) {
$borderStyle->setDiagonalDirection(Borders::DIAGONAL_DOWN); $borderStyle->setDiagonalDirection(Borders::DIAGONAL_DOWN);
}
} elseif ($diagonalDown === false) {
$borderStyle->setDiagonalDirection(Borders::DIAGONAL_UP);
} else { } else {
$borderStyle->setDiagonalDirection(Borders::DIAGONAL_BOTH); $borderStyle->setDiagonalDirection(Borders::DIAGONAL_BOTH);
} }

View File

@ -318,10 +318,7 @@ class Worksheet extends WriterPart
} }
// Set Zero Height row // Set Zero Height row
if ( if ($worksheet->getDefaultRowDimension()->getZeroHeight()) {
(string) $worksheet->getDefaultRowDimension()->getZeroHeight() === '1' ||
strtolower((string) $worksheet->getDefaultRowDimension()->getZeroHeight()) == 'true'
) {
$objWriter->writeAttribute('zeroHeight', '1'); $objWriter->writeAttribute('zeroHeight', '1');
} }
@ -1162,7 +1159,7 @@ class Worksheet extends WriterPart
$rowDimension = $worksheet->getRowDimension($currentRow); $rowDimension = $worksheet->getRowDimension($currentRow);
// Write current row? // Write current row?
$writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() == false || $rowDimension->getCollapsed() == true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null; $writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() === false || $rowDimension->getCollapsed() === true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null;
if ($writeCurrentRow) { if ($writeCurrentRow) {
// Start a new row // Start a new row