Problem/Motivation
Both when PHPStan analysis was introduced for Drupal, #3178534: Start running PHPStan on Drupal core (level 0), and when the rule level was upped to 1, #3190406: Update PHPStan to level 1, we added a baseline of errors that helped us to get the tool in, delegating to follow-ups the clean up of the baseline itself.
In those cases, the baseline consisted of approximately 1k errors.
Now, PHPStan level 2 rule reports (Nov 2022) more than 9k additional errors. Adding these to the baseline would make it hard to manage, so it ws suggested to start addressing PHPStan L2 fixes BEFORE actually bumpling the rule level in PHPStan configuration.
Proposed resolution
Use this meta to report the status of L2 PHPStan errors, open child issues to fix them until a reasonable (tbd) number is reached that could be added to the baseline.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3322735-5.patch | 4.73 KB | mondrake |
Comments
Comment #2
mondrakeA one-line patch to report the current status wrt PHPstan L2 errors. Please note that due to the large report, it is not fully displayed on the test results page. You need to go to the Jenkins job to get all of the details.
Comment #3
mondrakeComment #4
mondrakeComment #5
mondrakeComment #6
mondrakeIt looks like adding phpstan/phpstan-phpunit we would reduce approx 1k errors caused by unrecognized mocks
Comment #7
kingdutchAdded issue for L1 as related since I had a hard time figuring out the history of things and this aids in discovery.
Comment #8
andypostFiled child while faced #3352367: Fix Variable $graph might not be defined
Comment #10
bbralaNot sure about this web of issues, but think this is relevant here:
How to change signatures in interfaces has been documented: #3354524: Document how to add additional parameters to interface methods
Comment #11
mstrelan commentedProviding an update on the current stats:
HEAD (Level 1): 9606
HEAD (Level 2): 15067 (+5461)
HEAD + 3325057 (Level 2) 14636 (+5030)
When this issue was opened there were 9000+ additional errors, now we're down to around 5000.
EDIT: And another 906 errors fixed by adding
jangregor/phpstan-prophecy