From 189ca400ff1089251ba7d3097d8b52c0ea7ff1f5 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 21 Aug 2025 19:41:35 +0200 Subject: [PATCH] [TASK] Raise PHPStan to level 7 https://phpstan.org/user-guide/rule-levels --- config/phpstan-baseline.neon | 168 +++++++++++++++++++++++++++++++++++ config/phpstan.neon | 2 +- 2 files changed, 169 insertions(+), 1 deletion(-) diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index 6205096a..600c559f 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -6,12 +6,30 @@ parameters: count: 1 path: ../src/CSSList/CSSList.php + - + message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\CSSList\\CSSListItem\|false given\.$#' + identifier: if.condNotBoolean + count: 1 + path: ../src/CSSList/CSSList.php + + - + message: '#^Parameter \#1 \$animationName of method Sabberworm\\CSS\\CSSList\\KeyFrame\:\:setAnimationName\(\) expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/CSSList/CSSList.php + - message: '#^Parameter \#2 \$found of class Sabberworm\\CSS\\Parsing\\UnexpectedTokenException constructor expects string, Sabberworm\\CSS\\Value\\CSSFunction\|Sabberworm\\CSS\\Value\\CSSString\|Sabberworm\\CSS\\Value\\LineName\|Sabberworm\\CSS\\Value\\Size\|Sabberworm\\CSS\\Value\\URL given\.$#' identifier: argument.type count: 1 path: ../src/CSSList/CSSList.php + - + message: '#^Parameter \#2 \$found of class Sabberworm\\CSS\\Parsing\\UnexpectedTokenException constructor expects string, Sabberworm\\CSS\\Value\\CSSFunction\|Sabberworm\\CSS\\Value\\LineName\|Sabberworm\\CSS\\Value\\Size\|string given\.$#' + identifier: argument.type + count: 1 + path: ../src/CSSList/CSSList.php + - message: '#^Parameters should have "Sabberworm\\CSS\\CSSList\\CSSListItem\|array" types as the only types passed to this method$#' identifier: typePerfect.narrowPublicClassMethodParamType @@ -24,18 +42,72 @@ parameters: count: 1 path: ../src/CSSList/Document.php + - + message: '#^Method Sabberworm\\CSS\\Parsing\\ParserState\:\:parseIdentifier\(\) should return non\-empty\-string but returns string\.$#' + identifier: return.type + count: 1 + path: ../src/Parsing/ParserState.php + + - + message: '#^Method Sabberworm\\CSS\\Parsing\\ParserState\:\:strlen\(\) should return int\<0, max\> but returns int\<0, max\>\|false\.$#' + identifier: return.type + 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: '#^Property Sabberworm\\CSS\\Parsing\\ParserState\:\:\$currentPosition \(int\<0, max\>\) does not accept int\.$#' + identifier: assign.propertyType + count: 2 + path: ../src/Parsing/ParserState.php + + - + message: '#^Parameter \#1 \$separator of class Sabberworm\\CSS\\Value\\RuleValueList constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Rule/Rule.php + + - + message: '#^Parameter \#1 \$value of method Sabberworm\\CSS\\Rule\\Rule\:\:setValue\(\) expects Sabberworm\\CSS\\Value\\RuleValueList\|string\|null, Sabberworm\\CSS\\Value\\Value\|string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Rule/Rule.php + + - + message: '#^Cannot call method getSelector\(\) on Sabberworm\\CSS\\Property\\Selector\|string\.$#' + identifier: method.nonObject + count: 1 + path: ../src/RuleSet/DeclarationBlock.php + + - + message: '#^Method Sabberworm\\CSS\\RuleSet\\DeclarationBlock\:\:getSelectors\(\) should return array\ but returns array\\.$#' + identifier: return.type + count: 1 + path: ../src/RuleSet/DeclarationBlock.php + + - + message: '#^Parameter \#1 \$comments of method Sabberworm\\CSS\\RuleSet\\DeclarationBlock\:\:setComments\(\) expects list\, array\ given\.$#' + identifier: argument.type + count: 1 + path: ../src/RuleSet/DeclarationBlock.php + - message: '#^Parameters should have "string" types as the only types passed to this method$#' identifier: typePerfect.narrowPublicClassMethodParamType count: 1 path: ../src/RuleSet/DeclarationBlock.php + - + message: '#^Parameter \#1 \$name of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Value/CSSFunction.php + - message: '#^Parameter \#2 \$arguments of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects array\\|Sabberworm\\CSS\\Value\\RuleValueList, Sabberworm\\CSS\\Value\\Value\|string given\.$#' identifier: argument.type @@ -54,6 +126,24 @@ parameters: count: 3 path: ../src/Value/Color.php + - + message: '#^Parameter \#1 \$name of method Sabberworm\\CSS\\Value\\CSSFunction\:\:__construct\(\) expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Value/Color.php + + - + message: '#^Parameter \#1 \$name of method Sabberworm\\CSS\\Value\\CSSFunction\:\:setName\(\) expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Value/Color.php + + - + message: '#^Method Sabberworm\\CSS\\Value\\Size\:\:render\(\) should return non\-empty\-string but returns string\.$#' + identifier: return.type + count: 1 + path: ../src/Value/Size.php + - message: '#^Parameters should have "float" types as the only types passed to this method$#' identifier: typePerfect.narrowPublicClassMethodParamType @@ -66,6 +156,18 @@ parameters: count: 1 path: ../src/Value/Size.php + - + message: '#^Method Sabberworm\\CSS\\Value\\Value\:\:parseIdentifierOrFunction\(\) should return Sabberworm\\CSS\\Value\\CSSFunction\|string but returns Sabberworm\\CSS\\Value\\CSSFunction\|Sabberworm\\CSS\\Value\\URL\|string\.$#' + identifier: return.type + count: 1 + path: ../src/Value/Value.php + + - + message: '#^Parameter \#1 \$name of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../src/Value/Value.php + - message: '#^Parameter \#2 \$arguments of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects array\\|Sabberworm\\CSS\\Value\\RuleValueList, Sabberworm\\CSS\\Value\\Value\|string given\.$#' identifier: argument.type @@ -78,12 +180,36 @@ parameters: count: 1 path: ../src/Value/Value.php + - + message: '#^Parameter \#1 \$rule of class Sabberworm\\CSS\\Rule\\Rule constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 1 + path: ../tests/Functional/RuleSet/RuleSetTest.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 + - + message: '#^Cannot call method getListComponents\(\) on Sabberworm\\CSS\\Value\\RuleValueList\|string\.$#' + identifier: method.nonObject + count: 2 + path: ../tests/ParserTest.php + + - + message: '#^Cannot call method getListSeparator\(\) on Sabberworm\\CSS\\Value\\RuleValueList\|string\.$#' + identifier: method.nonObject + count: 2 + path: ../tests/ParserTest.php + + - + message: '#^Cannot call method render\(\) on Sabberworm\\CSS\\Value\\RuleValueList\|string\.$#' + identifier: method.nonObject + count: 1 + path: ../tests/ParserTest.php + - message: '#^Parameter \#1 \$value of method Sabberworm\\CSS\\Rule\\Rule\:\:setValue\(\) expects Sabberworm\\CSS\\Value\\RuleValueList\|string\|null, Sabberworm\\CSS\\Value\\Size given\.$#' identifier: argument.type @@ -113,3 +239,45 @@ parameters: identifier: argument.type count: 2 path: ../tests/Unit/CSSList/CSSListTest.php + + - + message: '#^Method Sabberworm\\CSS\\Tests\\Unit\\Comment\\CommentContainerTest\:\:provideAlternativeNonemptyCommentArray\(\) should return array\\}\> but returns array\\}\>\.$#' + identifier: return.type + count: 1 + path: ../tests/Unit/Comment/CommentContainerTest.php + + - + message: '#^Parameter \#1 \$numberOfSpaces of method Sabberworm\\CSS\\OutputFormat\:\:indentWithSpaces\(\) expects int\<1, max\>, int given\.$#' + identifier: argument.type + count: 1 + path: ../tests/Unit/OutputFormatTest.php + + - + message: '#^Parameter \#1 \$numberOfTabs of method Sabberworm\\CSS\\OutputFormat\:\:indentWithTabs\(\) expects int\<1, max\>, int given\.$#' + identifier: argument.type + count: 1 + path: ../tests/Unit/OutputFormatTest.php + + - + message: '#^Parameter \#1 \$lineNumber of method Sabberworm\\CSS\\Tests\\Unit\\Position\\Fixtures\\ConcretePosition\:\:setPosition\(\) expects int\<1, max\>\|null, int given\.$#' + identifier: argument.type + count: 2 + path: ../tests/Unit/Position/PositionTest.php + + - + message: '#^Parameter \#2 \$columnNumber of method Sabberworm\\CSS\\Tests\\Unit\\Position\\Fixtures\\ConcretePosition\:\:setPosition\(\) expects int\<0, max\>\|null, int given\.$#' + identifier: argument.type + count: 3 + path: ../tests/Unit/Position/PositionTest.php + + - + message: '#^Parameter \#1 \$rule of class Sabberworm\\CSS\\Rule\\Rule constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 19 + path: ../tests/Unit/RuleSet/DeclarationBlockTest.php + + - + message: '#^Parameter \#1 \$rule of class Sabberworm\\CSS\\Rule\\Rule constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type + count: 19 + path: ../tests/Unit/RuleSet/RuleSetTest.php diff --git a/config/phpstan.neon b/config/phpstan.neon index 55ba682a..33ad56a0 100644 --- a/config/phpstan.neon +++ b/config/phpstan.neon @@ -8,7 +8,7 @@ parameters: phpVersion: 70200 - level: 6 + level: 7 paths: - %currentWorkingDirectory%/bin/