-
Notifications
You must be signed in to change notification settings - Fork 390
Upgrade to PHPStan 2 #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Upgrade to PHPStan 2 #939
Changes from all commits
1dc68c6
f6c4630
de1d46f
6d38ebc
37fe471
f0ea604
41497dd
926dd9c
15f585e
7a24764
c7b53e1
f1b4405
d87732a
ab3ec58
2239ea6
d1802f4
a554484
4baa958
0513979
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,9 @@ | |
| "donatj/mock-webserver": "^2.7", | ||
| "friendsofphp/php-cs-fixer": "^2.19 || ^3.8", | ||
| "mf2/mf2": "^0.5.0", | ||
| "phpstan/phpstan": "~1.12.2", | ||
| "phpunit/phpunit": "^8 || ^9 || ^10", | ||
| "phpstan/phpstan": "~2.1.25", | ||
| "phpstan/phpstan-phpunit": "~2.0.7", | ||
| "phpunit/phpunit": "^8 || ^9", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Any idea why that is the case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional debugging welcome (but maybe not urgent). I am facing a symbol discovery issue when trying to support both PHPUnit >= 10 and PHP 7.2 at the same time |
||
| "psr/http-client": "^1.0", | ||
| "psr/http-factory": "^1.0", | ||
| "psr/simple-cache": "^1 || ^2 || ^3" | ||
|
|
@@ -69,7 +70,7 @@ | |
| "coverage": "phpunit --coverage-html=.phpunit.cache/code-coverage", | ||
| "cs": "php-cs-fixer fix --verbose --dry-run --diff", | ||
| "fix": "php-cs-fixer fix --verbose --diff", | ||
| "phpstan": "phpstan analyze --memory-limit 512M", | ||
Alkarex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "phpstan": "phpstan analyse --memory-limit 512M", | ||
| "test": "phpunit" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| parameters: | ||
| phpVersion: | ||
| min: 70200 # PHP 7.2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looks like it uses the requires field: |
||
| max: 80599 # PHP 8.5 | ||
|
|
||
| level: 8 | ||
|
|
||
| paths: | ||
|
|
@@ -7,54 +11,15 @@ parameters: | |
| - tests/ | ||
| - utils/ | ||
|
|
||
| ignoreErrors: | ||
| # Ignore that only one const exists atm | ||
| - | ||
| message: "#^Strict comparison using \\!\\=\\= between 'GET' and 'GET' will always evaluate to false\\.$#" | ||
| count: 1 | ||
| path: src/HTTP/Psr18Client.php | ||
|
|
||
| # Not used since https://github.com/simplepie/simplepie/commit/b2eb0134d53921e75f0fa70b1cf901ed82b988b1 but cannot be removed due to BC. | ||
| - '(Constructor of class SimplePie\\Enclosure has an unused parameter \$javascript\.)' | ||
|
|
||
| # Testing legacy dynamic property usage. | ||
| - '(Access to an undefined property SimplePie.IRI::\$nonexistent_prop\.)' | ||
|
|
||
| - | ||
| message: '(^Strict comparison using === between string and false will always evaluate to false\.$)' | ||
| count: 1 | ||
| path: src/HTTP/Parser.php | ||
| # Only occurs on PHP ≥ 8.0 | ||
| reportUnmatched: false | ||
|
|
||
| - | ||
| message: '(^Strict comparison using === between string and false will always evaluate to false\.$)' | ||
| count: 1 | ||
| path: src/IRI.php | ||
| # Only occurs on PHP ≥ 8.0 | ||
| reportUnmatched: false | ||
|
|
||
| - | ||
| message: '(^Parameter #1 \$exception of method PHPUnit\\Framework\\TestCase::expectException\(\) expects class-string<Throwable>, string given\.$)' | ||
|
|
||
| count: 3 | ||
| path: tests/Unit/Cache/Psr16Test.php | ||
| # Only occurs on PHP ≤ 7.4 | ||
| reportUnmatched: false | ||
|
|
||
| - | ||
| message: '(^Parameter \$parser of method SimplePie\\Parser::(tag_open|cdata|tag_close)\(\) has invalid type XMLParser\.$)' | ||
|
|
||
| count: 3 | ||
| path: src/Parser.php | ||
| # Only occurs on PHP ≤ 7.4 | ||
| reportUnmatched: false | ||
| excludePaths: | ||
| analyseAndScan: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? None of these are listed under
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, mainly because it may be interesting to run PHPStan manually on selected parts of the code base.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| - .git/*? | ||
| - build/*? | ||
| - vendor/* | ||
|
|
||
| # PHPStan stubs bug https://github.com/phpstan/phpstan/issues/8629 | ||
| - | ||
| message: '(^Access to an undefined property XMLReader::\$\w+\.$)' | ||
| # Only occurs on PHP ≥ 8.2 | ||
| reportUnmatched: false | ||
| treatPhpDocTypesAsCertain: false # TODO: Fix | ||
|
|
||
| includes: | ||
| - utils/PHPStan/extension.neon | ||
| - vendor/phpstan/phpstan-phpunit/extension.neon | ||
| - vendor/phpstan/phpstan-phpunit/rules.neon | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handling that properly in #969 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Older PHP versions have quirks that sometimes need to be accounted for. IIRC, running PHPStan on those versions could sometimes point them out.
Though we cannot use PHPStan 2 on unsupported versions (and trying to support both PHPStan 1.0 and 2.0 would be too much) so the versions that would benefit from it the most will not be covered.
Even PHPStan itself runs static analysis on the complete compatible subset of the matrix: https://github.com/phpstan/phpstan-src/blob/53e98f9975b28de5d55b7b37cce3dcfc4adfca0e/.github/workflows/static-analysis.yml#L82-L87
🤷♀️
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From PHPStan 2.0, which supports a PHP version range, variations between PHP versions on the whole range are accounted for, for instance PHP functions that have changed signature over time. I am not aware of cases where it would make a difference to run PHPStan on multiple PHP versions, since the same rules will be checked (as opposed to PHPStan 1.x, where it could make a difference)