Skip to content

Commit

Permalink
[TASK] Move and polish the PHPStan configuration and scripts (#1378)
Browse files Browse the repository at this point in the history
Move the configuration and baseline files to `config/` in order
to declutter the project main directory (following our sister
project).

Stop using the GitHub formatter as this makes it impossible for
humans to see any errors if the CI pipeline fails.
  • Loading branch information
oliverklee authored Dec 17, 2024
1 parent b408be1 commit 3cd0d45
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 43 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
/CONTRIBUTING.md export-ignore
/config/ export-ignore
/docs/ export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/tests/ export-ignore
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"ci:php:lint": "parallel-lint config src tests",
"ci:php:md": "\"./.phive/phpmd\" src text config/phpmd.xml",
"ci:php:rector": "rector --no-progress-bar --dry-run --config=config/rector.php",
"ci:php:stan": "phpstan --no-progress --error-format=github",
"ci:php:stan": "phpstan --no-progress --configuration=config/phpstan.neon",
"ci:static": [
"@ci:composer:normalize",
"@ci:php:lint",
Expand All @@ -116,7 +116,7 @@
"fix:php:fixer": "\"./.phive/php-cs-fixer\" --config=config/php-cs-fixer.php fix config/ src/ tests/",
"fix:php:rector": "rector --config=config/rector.php",
"php:version": "@php -v | grep -Po 'PHP\\s++\\K(?:\\d++\\.)*+\\d++(?:-\\w++)?+'",
"phpstan:baseline": "phpstan --generate-baseline --allow-empty-baseline"
"phpstan:baseline": "phpstan --configuration=config/phpstan.neon --generate-baseline=config/phpstan-baseline.neon --allow-empty-baseline"
},
"scripts-descriptions": {
"ci": "Runs all dynamic and static code checks.",
Expand Down
72 changes: 36 additions & 36 deletions phpstan-baseline.neon → config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,163 +4,163 @@ parameters:
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
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
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
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
path: ../src/CssInliner.php

-
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
path: ../src/HtmlProcessor/AbstractHtmlProcessor.php

-
message: '#^Unsafe usage of new static\(\)\.$#'
identifier: new.static
count: 2
path: src/HtmlProcessor/AbstractHtmlProcessor.php
path: ../src/HtmlProcessor/AbstractHtmlProcessor.php

-
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
path: ../src/HtmlProcessor/CssToAttributeConverter.php

-
message: '#^Method Pelago\\Emogrifier\\HtmlProcessor\\CssToAttributeConverter\:\:getAllNodesWithStyleAttribute\(\) should return DOMNodeList but returns DOMNodeList\<DOMNode\>\|false\.$#'
identifier: return.type
count: 1
path: src/HtmlProcessor/CssToAttributeConverter.php
path: ../src/HtmlProcessor/CssToAttributeConverter.php

-
message: '#^Argument of an invalid type DOMNodeList\<DOMNode\>\|false supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
count: 1
path: src/HtmlProcessor/HtmlPruner.php
path: ../src/HtmlProcessor/HtmlPruner.php

-
message: '#^Cannot access property \$length on DOMNodeList\<DOMNode\>\|false\.$#'
identifier: property.nonObject
count: 1
path: src/HtmlProcessor/HtmlPruner.php
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$#'
identifier: missingType.generics
count: 1
path: src/HtmlProcessor/HtmlPruner.php
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$#'
identifier: missingType.generics
count: 1
path: src/HtmlProcessor/HtmlPruner.php
path: ../src/HtmlProcessor/HtmlPruner.php

-
message: '#^Offset 1 might not exist on array\<int, array\<int, string\>\>\|null\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/HtmlProcessor/HtmlPruner.php
path: ../src/HtmlProcessor/HtmlPruner.php

-
message: '#^Parameter \#1 \$elements of method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassAttributeFromElements\(\) expects DOMNodeList, DOMNodeList\<DOMNode\>\|false given\.$#'
identifier: argument.type
count: 1
path: src/HtmlProcessor/HtmlPruner.php
path: ../src/HtmlProcessor/HtmlPruner.php

-
message: '#^Parameter \#1 \$elements of method Pelago\\Emogrifier\\HtmlProcessor\\HtmlPruner\:\:removeClassesFromElements\(\) expects DOMNodeList, DOMNodeList\<DOMNode\>\|false given\.$#'
identifier: argument.type
count: 1
path: src/HtmlProcessor/HtmlPruner.php
path: ../src/HtmlProcessor/HtmlPruner.php

-
message: '#^Property object\{media\: string, ruleBlocks\: array\<int, object\{selectorsAsKeys\: array\<string, \(int\|string\)\>, declarationsBlock\: string\}\>\}\:\:\$ruleBlocks is not writable\.$#'
identifier: assign.propertyReadOnly
count: 1
path: src/Utilities/CssConcatenator.php
path: ../src/Utilities/CssConcatenator.php

-
message: '#^Property object\{selectorsAsKeys\: array\<string, \(int\|string\)\>, declarationsBlock\: string\}\:\:\$declarationsBlock is not writable\.$#'
identifier: assign.propertyReadOnly
count: 1
path: src/Utilities/CssConcatenator.php
path: ../src/Utilities/CssConcatenator.php

-
message: '#^Property object\{selectorsAsKeys\: array\<string, \(int\|string\)\>, declarationsBlock\: string\}\:\:\$selectorsAsKeys is not writable\.$#'
identifier: assign.propertyReadOnly
count: 1
path: src/Utilities/CssConcatenator.php
path: ../src/Utilities/CssConcatenator.php

-
message: '#^Offset 1 might not exist on array\<int, string\>\|null\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/Utilities/DeclarationBlockParser.php
path: ../src/Utilities/DeclarationBlockParser.php

-
message: '#^Offset 2 might not exist on array\<int, string\>\|null\.$#'
identifier: offsetAccess.notFound
count: 1
path: src/Utilities/DeclarationBlockParser.php
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
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
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
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
path: ../src/Utilities/Preg.php

-
message: '#^Parameter \#1 \$array of function array_flip expects array\<int\|string\>, array\<string, mixed\> given\.$#'
identifier: argument.type
count: 1
path: src/Utilities/Preg.php
path: ../src/Utilities/Preg.php

-
message: '#^Parameter &\$matches by\-ref type of method Pelago\\Emogrifier\\Utilities\\Preg\:\:match\(\) expects array\<int, string\>\|null, array\<string\> given\.$#'
identifier: parameterByRef.type
count: 1
path: src/Utilities/Preg.php
path: ../src/Utilities/Preg.php

-
message: '#^Parameter &\$matches by\-ref type of method Pelago\\Emogrifier\\Utilities\\Preg\:\:matchAll\(\) expects array\<int, array\<int, string\>\>\|null, array\<list\<string\>\> given\.$#'
identifier: parameterByRef.type
count: 1
path: src/Utilities/Preg.php
path: ../src/Utilities/Preg.php

-
message: '''
Expand All @@ -170,7 +170,7 @@ parameters:
'''
identifier: phpunit.dataProviderMethod
count: 1
path: tests/Unit/Css/CssDocumentTest.php
path: ../tests/Unit/Css/CssDocumentTest.php

-
message: '''
Expand All @@ -180,46 +180,46 @@ parameters:
'''
identifier: phpunit.dataProviderMethod
count: 1
path: tests/Unit/Css/CssDocumentTest.php
path: ../tests/Unit/Css/CssDocumentTest.php

-
message: '#^Offset 0 might not exist on array\<int, string\>\|null\.$#'
identifier: offsetAccess.notFound
count: 1
path: tests/Unit/Css/CssDocumentTest.php
path: ../tests/Unit/Css/CssDocumentTest.php

-
message: '#^Parameter \#1 \$string of function trim expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: tests/Unit/CssInlinerTest.php
path: ../tests/Unit/CssInlinerTest.php

-
message: '#^Parameter \#1 \$string of function strtolower expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php
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
path: ../tests/Unit/HtmlProcessor/AbstractHtmlProcessorTest.php

-
message: '#^Offset 1 might not exist on array\<int, array\<int, string\>\>\|null\.$#'
identifier: offsetAccess.notFound
count: 1
path: tests/Unit/HtmlProcessor/HtmlPrunerTest.php
path: ../tests/Unit/HtmlProcessor/HtmlPrunerTest.php

-
message: '#^Parameter \#1 \$array of function array_filter expects array, array\<int, array\<int, string\>\>\|null given\.$#'
identifier: argument.type
count: 1
path: tests/Unit/Utilities/PregTest.php
path: ../tests/Unit/Utilities/PregTest.php

-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertCount\(\) expects Countable\|iterable, array\<int, array\<int, string\>\>\|null given\.$#'
identifier: argument.type
count: 1
path: tests/Unit/Utilities/PregTest.php
path: ../tests/Unit/Utilities/PregTest.php
6 changes: 3 additions & 3 deletions phpstan.neon → config/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ parameters:
level: 9

paths:
- src
- tests
- %currentWorkingDirectory%/src/
- %currentWorkingDirectory%/tests/

ignoreErrors:
-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) .* will always evaluate to#'
path: 'tests/'
path: '%currentWorkingDirectory%/tests/'

0 comments on commit 3cd0d45

Please sign in to comment.