From 2da85155bdafd1d30fc1a94aec3260625f2a3c4a Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 21 Sep 2023 11:13:50 +0800 Subject: [PATCH] Fix PHPStan errors --- phpstan-baseline.neon | 17 +---------------- .../Calculation/FormulaParser.php | 18 +++++------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 153d22fea..c7cbf42ca 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7,22 +7,7 @@ parameters: - message: "#^Cannot call method getTokenType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 9 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php - - - - message: "#^Cannot call method setTokenSubType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 5 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php - - - - message: "#^Cannot call method setValue\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 5 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php - - - - message: "#^Strict comparison using \\=\\=\\= between PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken and null will always evaluate to false\\.$#" - count: 1 + count: 8 path: src/PhpSpreadsheet/Calculation/FormulaParser.php - diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 79911b0a4..cffce179c 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -299,6 +299,7 @@ class FormulaParser $value = ''; } + /** @var FormulaToken $tmp */ $tmp = array_pop($stack); $tmp->setValue(''); $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP); @@ -322,11 +323,13 @@ class FormulaParser $value = ''; } + /** @var FormulaToken $tmp */ $tmp = array_pop($stack); $tmp->setValue(''); $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP); $tokens1[] = $tmp; + /** @var FormulaToken $tmp */ $tmp = array_pop($stack); $tmp->setValue(''); $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP); @@ -414,6 +417,7 @@ class FormulaParser $value = ''; } + /** @var FormulaToken $tmp */ $tmp = array_pop($stack); $tmp->setValue(''); $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP); @@ -436,6 +440,7 @@ class FormulaParser $value = ''; } + /** @var FormulaToken $tmp */ $tmp = array_pop($stack); $tmp->setValue(''); $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP); @@ -471,10 +476,6 @@ class FormulaParser $nextToken = null; } - if ($token === null) { - continue; - } - if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) { $tokens2[] = $token; @@ -524,15 +525,6 @@ class FormulaParser } else { $previousToken = null; } - //if (isset($tokens2[$i + 1])) { - // $nextToken = $tokens2[$i + 1]; - //} else { - // $nextToken = null; - //} - - if ($token === null) { - continue; - } if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') { if ($i == 0) {