-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Run static analysis on PHP 8.1 #9310
Conversation
This will make it easier to add code that leverages features only defined since that version of PHP.
I agree that we should analyze the codebase on PHP 8.1. While PHP 7.1 is the lowest supported version, the repository contains features that require a more recent PHP version and we are currently hardly able to run static analysis on those parts. Just raising the PHP interpreter version is not enough however. We need to toll both tools to apply PHP 8.1 rules. This is where you can do this for PHPStan: Line 11 in d30e748
For Psalm, you need to add the attribute |
Moreover, rasining the language level should allow us to drop some hacks from Psalm's configuration: Lines 90 to 96 in d30e748
Lines 103 to 108 in d30e748
|
@derrabus I'm not aiming at testing PHP 8.1 features with this PR, I'm aiming at preventing them from making the baseline grow. If we want to test our usage of PHP 8.1 features, while still checking that our code is compatible with our lowest supported version (we want to do that, right?), we will had to rework the static analysis jobs. Do we still want to have jobs with 7.1 as a target version? |
Does it really make a difference if we bump the PHP runtime only? Both tools will still assume PHP 7.1 as language level.
Right now, letting the tools operate PHP 7.1 as language level causes more pain than it solves problems imho. Especially Psalm has a history of reporting funny errors if the dependencies are on a higher language level. I'd suggest to let the test suite cover PHP 7.1 support and let the SA tools operate on PHP 8.1. |
If you like, we can merge this PR as-is and I work out a PR for bumping the language level for the SA tools. |
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.
Agree about PHPUnit covering 7.1 is good enough.
I've implemented my suggestion as #9314. |
* 2.11.x: Run PHP CodeSniffer on PHP 8.1 (doctrine#9317) Psalm 4.17.0 (doctrine#9315) Run static analysis on PHP 8.1 (doctrine#9310)
* 2.11.x: Run static analysis with language level PHP 8.1 (doctrine#9314) Document LockMode enums (doctrine#9319) Document PHPUnit mocks with intersection types (doctrine#9318) Run PHP CodeSniffer on PHP 8.1 (doctrine#9317) Psalm 4.17.0 (doctrine#9315) Run static analysis on PHP 8.1 (doctrine#9310)
This will make it easier to add code that leverages features only
defined since that version of PHP.