Problem/Motivation
Thanks to #3579177: Enable GitLab CI and fix pipelines we're now running phpstan on our codebase. However, we're still using the default level of 0, which is only catching the bare minimum of problems. It'd be nice to get to a higher level and see how much that can help us both cleanup our existing code and to prevent new MRs from introducing regressions.
I'm also curious about this since I was confused that in D9 there's a deprecation about extra arguments to test assertion methods like statusCodeEquals(), which I was assuming would start throwing exceptions in D10 and up (as the deprecation message said), but that doesn't actually happen. When I asked why, I was pointed to #3322961: Fix WebAssert since PHPStan can now check the number of arguments passed to methods. So it seems that at least core is relying on being at a higher PHPStan level to catch problems like this.
Steps to reproduce
Proposed resolution
Bump the PHPStan level. See what happens. Fix what we can, baseline the rest. Repeat.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork forward-3579288
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3579288-raise-phpstan-level
changes, plain diff MR !12
Comments
Comment #3
dwwNice. Locally I got us up to level 5 with fairly minimal changes, and some of them definitely helped catch some weirdness.
Bumping to level 6 starts to get really noisy, 125 new errors, basically requiring that all params and return values are typed, which is more of a change than I'm in the mood for, potentially BC breaking, and perhaps requiring a new major version. No thanks. 😅
But IMHO this is already a big improvement, so I'd be happy to merge this.
p.s. I put another argument at the end of one of those
statusCodeEquals()calls inPermissionsTestand lo, it would now be flagged:Huzzah.
Comment #6
dwwI don't see any reason not to do this. Merged.