diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e728bd49..f1c3d5c0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,9 +17,11 @@ updates: allow: - dependency-type: "development" ignore: + - dependency-name: "phpstan/*" - dependency-name: "phpunit/phpunit" versions: [ ">= 10.0.0" ] - dependency-name: "rawr/cross-data-providers" + - dependency-name: "rector/rector" versioning-strategy: "increase" commit-message: prefix: "[Dependabot] " diff --git a/composer.json b/composer.json index 4a719269..49d7abe0 100644 --- a/composer.json +++ b/composer.json @@ -46,13 +46,13 @@ "require-dev": { "php-parallel-lint/php-parallel-lint": "1.4.0", "phpstan/extension-installer": "1.4.3", - "phpstan/phpstan": "1.12.9", - "phpstan/phpstan-phpunit": "1.4.0", - "phpstan/phpstan-strict-rules": "1.6.1", + "phpstan/phpstan": "1.12.12 || 2.0.3", + "phpstan/phpstan-phpunit": "1.4.1 || 2.0.1", + "phpstan/phpstan-strict-rules": "1.6.1 || 2.0.0", "phpunit/phpunit": "9.6.22", "rawr/cross-data-providers": "2.4.0", "rawr/phpunit-data-provider": "3.3.0", - "rector/rector": "1.2.10" + "rector/rector": "1.2.10 || 2.0.0" }, "prefer-stable": true, "autoload": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4469036e..8c65a7b7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,96 +1,309 @@ parameters: ignoreErrors: - - message: "#^Method Pelago\\\\Emogrifier\\\\CssInliner\\:\\:getAllNodesWithStyleAttribute\\(\\) return type with generic class DOMNodeList does not specify its types\\: TNode$#" + message: '#^Method Pelago\\Emogrifier\\Caching\\SimpleStringCache\:\:set\(\) has BadMethodCallException in PHPDoc @throws tag but it''s not thrown\.$#' + identifier: throws.unusedType + count: 1 + path: src/Caching/SimpleStringCache.php + + - + message: '#^PHPDoc tag @var with type Sabberworm\\CSS\\Renderable is not subtype of type Sabberworm\\CSS\\CSSList\\CSSList\|Sabberworm\\CSS\\Property\\Charset\|Sabberworm\\CSS\\Property\\Import\|Sabberworm\\CSS\\RuleSet\\RuleSet\.$#' + identifier: varTag.type + count: 2 + path: src/Css/CssDocument.php + + - + message: '#^Method Pelago\\Emogrifier\\CssInliner\:\:getAllNodesWithStyleAttribute\(\) return type with generic class DOMNodeList does not specify its types\: TNode$#' + identifier: missingType.generics + count: 1 + path: src/CssInliner.php + + - + message: '#^Only numeric types are allowed in \*, int\|null given on the right side\.$#' + identifier: mul.rightNonNumeric count: 1 path: src/CssInliner.php - - message: "#^Parameter \\#1 \\$html of method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor\\:\\:removeSelfClosingTagsClosingTags\\(\\) expects string, string\\|false given\\.$#" + message: '#^Parameter \#1 \$html of method Pelago\\Emogrifier\\HtmlProcessor\\AbstractHtmlProcessor\:\:removeSelfClosingTagsClosingTags\(\) expects string, string\|false given\.$#' + identifier: argument.type count: 2 path: src/HtmlProcessor/AbstractHtmlProcessor.php - - message: "#^Unsafe usage of new static\\(\\)\\.$#" + message: '#^Unsafe usage of new static\(\)\.$#' + identifier: new.static count: 2 path: src/HtmlProcessor/AbstractHtmlProcessor.php - - message: "#^Method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\CssToAttributeConverter\\:\\:getAllNodesWithStyleAttribute\\(\\) return type with generic class DOMNodeList does not specify its types\\: TNode$#" + message: '#^Method Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter\:\:getAllNodesWithStyleAttribute\(\) return type with generic class DOMNodeList does not specify its types\: TNode$#' + identifier: missingType.generics count: 1 path: src/HtmlProcessor/CssToAttributeConverter.php - - message: "#^Method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\CssToAttributeConverter\\:\\:getAllNodesWithStyleAttribute\\(\\) should return DOMNodeList but returns DOMNodeList\\\\|false\\.$#" + message: '#^Method Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter\:\:getAllNodesWithStyleAttribute\(\) should return DOMNodeList but returns DOMNodeList\\|false\.$#' + identifier: return.type count: 1 path: src/HtmlProcessor/CssToAttributeConverter.php - - message: "#^Argument of an invalid type DOMNodeList\\\\|false supplied for foreach, only iterables are supported\\.$#" + message: '#^Argument of an invalid type DOMNodeList\\|false supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable + count: 1 + path: src/HtmlProcessor/HtmlPruner.php + + - + message: '#^Cannot access property \$length on DOMNodeList\\|false\.$#' + identifier: property.nonObject count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Cannot access property \\$length on DOMNodeList\\\\|false\\.$#" + message: '#^Method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassAttributeFromElements\(\) has parameter \$elements with generic class DOMNodeList but does not specify its types\: TNode$#' + identifier: missingType.generics count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlPruner\\:\\:removeClassAttributeFromElements\\(\\) has parameter \\$elements with generic class DOMNodeList but does not specify its types\\: TNode$#" + message: '#^Method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassesFromElements\(\) has parameter \$elements with generic class DOMNodeList but does not specify its types\: TNode$#' + identifier: missingType.generics count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlPruner\\:\\:removeClassesFromElements\\(\\) has parameter \\$elements with generic class DOMNodeList but does not specify its types\\: TNode$#" + message: '#^Offset 1 might not exist on array\\>\|null\.$#' + identifier: offsetAccess.notFound count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Parameter \\#1 \\$elements of method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlPruner\\:\\:removeClassAttributeFromElements\\(\\) expects DOMNodeList, DOMNodeList\\\\|false given\\.$#" + message: '#^Parameter \#1 \$elements of method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassAttributeFromElements\(\) expects DOMNodeList, DOMNodeList\\|false given\.$#' + identifier: argument.type count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Parameter \\#1 \\$elements of method Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlPruner\\:\\:removeClassesFromElements\\(\\) expects DOMNodeList, DOMNodeList\\\\|false given\\.$#" + message: '#^Parameter \#1 \$elements of method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassesFromElements\(\) expects DOMNodeList, DOMNodeList\\|false given\.$#' + identifier: argument.type count: 1 path: src/HtmlProcessor/HtmlPruner.php - - message: "#^Property object\\{media\\: string, ruleBlocks\\: array\\, declarationsBlock\\: string\\}\\>\\}\\:\\:\\$ruleBlocks is not writable\\.$#" + message: '#^Property object\{media\: string, ruleBlocks\: array\, declarationsBlock\: string\}\>\}\:\:\$ruleBlocks is not writable\.$#' + identifier: assign.propertyReadOnly count: 1 path: src/Utilities/CssConcatenator.php - - message: "#^Property object\\{selectorsAsKeys\\: array\\, declarationsBlock\\: string\\}\\:\\:\\$declarationsBlock is not writable\\.$#" + message: '#^Property object\{selectorsAsKeys\: array\, declarationsBlock\: string\}\:\:\$declarationsBlock is not writable\.$#' + identifier: assign.propertyReadOnly count: 1 path: src/Utilities/CssConcatenator.php - - message: "#^Property object\\{selectorsAsKeys\\: array\\, declarationsBlock\\: string\\}\\:\\:\\$selectorsAsKeys is not writable\\.$#" + message: '#^Property object\{selectorsAsKeys\: array\, declarationsBlock\: string\}\:\:\$selectorsAsKeys is not writable\.$#' + identifier: assign.propertyReadOnly count: 1 path: src/Utilities/CssConcatenator.php - - message: "#^Parameter \\#1 \\$array of function array_filter expects array, mixed given\\.$#" + message: '#^Offset 1 might not exist on array\\|null\.$#' + identifier: offsetAccess.notFound + count: 1 + path: src/Utilities/DeclarationBlockParser.php + + - + message: '#^Offset 2 might not exist on array\\|null\.$#' + identifier: offsetAccess.notFound + count: 1 + path: src/Utilities/DeclarationBlockParser.php + + - + message: '#^Method Pelago\\Emogrifier\\Utilities\\Preg\:\:match\(\) never assigns null to &\$matches so it can be removed from the by\-ref type\.$#' + identifier: parameterByRef.unusedType + count: 1 + path: src/Utilities/Preg.php + + - + message: '#^Method Pelago\\Emogrifier\\Utilities\\Preg\:\:matchAll\(\) never assigns null to &\$matches so it can be removed from the by\-ref type\.$#' + identifier: parameterByRef.unusedType + count: 1 + path: src/Utilities/Preg.php + + - + message: '#^Method Pelago\\Emogrifier\\Utilities\\Preg\:\:replace\(\) never assigns null to &\$count so it can be removed from the by\-ref type\.$#' + identifier: parameterByRef.unusedType + count: 1 + path: src/Utilities/Preg.php + + - + message: '#^Method Pelago\\Emogrifier\\Utilities\\Preg\:\:replaceCallback\(\) never assigns null to &\$count so it can be removed from the by\-ref type\.$#' + identifier: parameterByRef.unusedType + count: 1 + path: src/Utilities/Preg.php + + - + message: '#^Parameter \#1 \$array of function array_flip expects array\, array\ given\.$#' + identifier: argument.type count: 1 path: src/Utilities/Preg.php - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + message: '#^Parameter &\$matches by\-ref type of method Pelago\\Emogrifier\\Utilities\\Preg\:\:match\(\) expects array\\|null, array\ given\.$#' + identifier: parameterByRef.type count: 1 path: src/Utilities/Preg.php - - message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#" + message: '#^Parameter &\$matches by\-ref type of method Pelago\\Emogrifier\\Utilities\\Preg\:\:matchAll\(\) expects array\\>\|null, array\\> given\.$#' + identifier: parameterByRef.type + count: 1 + path: src/Utilities/Preg.php + + - + message: ''' + #^@dataProvider provideInvalidAtCharsetRuleWhichCausesException + + Invalid related method not found\.$# + ''' + identifier: phpunit.dataProviderMethod + count: 1 + path: tests/Unit/Css/CssDocumentTest.php + + - + message: ''' + #^@dataProvider provideInvalidNonConditionalAtRuleWhichCausesException + + Invalid related method not found\.$# + ''' + identifier: phpunit.dataProviderMethod + count: 1 + path: tests/Unit/Css/CssDocumentTest.php + + - + message: '#^Offset 0 might not exist on array\\|null\.$#' + identifier: offsetAccess.notFound + count: 1 + path: tests/Unit/Css/CssDocumentTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\CssInliner'' and Pelago\\Emogrifier\\CssInliner will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType count: 1 path: tests/Unit/CssInlinerTest.php - - message: "#^Parameter \\#1 \\$string of function strtolower expects string, string\\|false given\\.$#" + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor'' and Pelago\\Emogrifier\\CssInliner will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType count: 1 + path: tests/Unit/CssInlinerTest.php + + - + message: '#^Parameter \#1 \$string of function trim expects string, string\|false given\.$#' + identifier: argument.type + count: 1 + path: tests/Unit/CssInlinerTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''DOMDocument'' and DOMDocument will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor'' and Pelago\\Emogrifier\\Tests\\Unit\\HtmlProcessor\\Fixtures\\TestingHtmlProcessor will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php - - message: "#^Parameter \\#2 \\$actual of static method Pelago\\\\Emogrifier\\\\Tests\\\\Unit\\\\HtmlProcessor\\\\AbstractHtmlProcessorTest\\:\\:assertEqualsHtml\\(\\) expects string, string\\|false given\\.$#" + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\Tests\\\\Unit\\\\HtmlProcessor\\\\Fixtures\\\\TestingHtmlProcessor'' and Pelago\\Emogrifier\\Tests\\Unit\\HtmlProcessor\\Fixtures\\TestingHtmlProcessor will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 + path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php + + - + message: '#^Parameter \#1 \$string of function strtolower expects string, string\|false given\.$#' + identifier: argument.type count: 1 path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php + + - + message: '#^Parameter \#2 \$actual of static method Pelago\\Emogrifier\\Tests\\Unit\\HtmlProcessor\\AbstractHtmlProcessorTest\:\:assertEqualsHtml\(\) expects string, string\|false given\.$#' + identifier: argument.type + count: 1 + path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor'' and Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/HtmlProcessor/CssToAttributeConverterTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\CssToAttributeConverter'' and Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 + path: tests/Unit/HtmlProcessor/CssToAttributeConverterTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor'' and Pelago\\Emogrifier\\HtmlProcessor\\HtmlNormalizer will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/HtmlProcessor/HtmlNormalizerTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlNormalizer'' and Pelago\\Emogrifier\\HtmlProcessor\\HtmlNormalizer will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 + path: tests/Unit/HtmlProcessor/HtmlNormalizerTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\AbstractHtmlProcessor'' and Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/HtmlProcessor/HtmlPrunerTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Pelago\\\\Emogrifier\\\\HtmlProcessor\\\\HtmlPruner'' and Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 + path: tests/Unit/HtmlProcessor/HtmlPrunerTest.php + + - + message: '#^Offset 1 might not exist on array\\>\|null\.$#' + identifier: offsetAccess.notFound + count: 1 + path: tests/Unit/HtmlProcessor/HtmlPrunerTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''PHPUnit\\\\Framework\\\\Constraint\\\\Constraint'' and Pelago\\Emogrifier\\Tests\\Support\\Constraint\\IsEquivalentCss will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/Support/Traits/AssertCssTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''PHPUnit\\\\Framework\\\\Constraint\\\\Constraint'' and Pelago\\Emogrifier\\Tests\\Support\\Constraint\\StringContainsCss will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/Support/Traits/AssertCssTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''PHPUnit\\\\Framework\\\\Constraint\\\\Constraint'' and Pelago\\Emogrifier\\Tests\\Support\\Constraint\\StringContainsCssCount will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Unit/Support/Traits/AssertCssTest.php + + - + message: '#^Parameter \#1 \$array of function array_filter expects array, array\\>\|null given\.$#' + identifier: argument.type + count: 1 + path: tests/Unit/Utilities/PregTest.php + + - + message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertCount\(\) expects Countable\|iterable, array\\>\|null given\.$#' + identifier: argument.type + count: 1 + path: tests/Unit/Utilities/PregTest.php diff --git a/phpstan.neon b/phpstan.neon index 07748b62..94aebbde 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,6 +7,3 @@ parameters: paths: - src - tests - - # Allow instanceof checks, particularly in tests - checkAlwaysTrueCheckTypeFunctionCall: false