From a20a357e084d28f6550ef545ccdf71ed5dff429f Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Wed, 19 Mar 2025 22:35:58 +0100 Subject: [PATCH] [TASK] Raise PHPStan to level 4 Also allow `assertInstanceOf` checks in the tests (as we find those useful). --- config/phpstan-baseline.neon | 30 ++++++++++++++++++++++++++++++ config/phpstan.neon | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index f84a4a00..0bc75c4c 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -6,6 +6,12 @@ parameters: count: 1 path: ../src/CSSList/AtRuleBlockList.php + - + message: '#^Call to function is_string\(\) with Sabberworm\\CSS\\Parsing\\ParserState will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: ../src/CSSList/CSSList.php + - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed @@ -36,6 +42,18 @@ parameters: count: 1 path: ../src/CSSList/Document.php + - + message: '#^Call to function in_array\(\) with arguments null, list\ and true will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: ../src/Parsing/ParserState.php + + - + message: '#^Negated boolean expression is always true\.$#' + identifier: booleanNot.alwaysTrue + count: 1 + path: ../src/Parsing/ParserState.php + - message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\Value\\RuleValueList\|string\|null given\.$#' identifier: if.condNotBoolean @@ -89,3 +107,15 @@ parameters: identifier: typePerfect.narrowPublicClassMethodParamType count: 1 path: ../src/Value/Size.php + + - + message: '#^Strict comparison using \!\=\= between non\-empty\-string and null will always evaluate to true\.$#' + identifier: notIdentical.alwaysTrue + count: 1 + path: ../src/Value/Size.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with ''red'' and Sabberworm\\CSS\\Value\\Value will always evaluate to false\.$#' + identifier: staticMethod.impossibleType + count: 1 + path: ../tests/ParserTest.php diff --git a/config/phpstan.neon b/config/phpstan.neon index 6a410ac2..9eee8659 100644 --- a/config/phpstan.neon +++ b/config/phpstan.neon @@ -8,7 +8,7 @@ parameters: phpVersion: 70200 - level: 3 + level: 4 paths: - %currentWorkingDirectory%/bin/ @@ -21,3 +21,8 @@ parameters: null_over_false: true narrow_param: true narrow_return: true + + ignoreErrors: + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) .* will always evaluate to#' + path: '../tests/'