Problem/Motivation
We are trying to reduce the L2 phpstan baseline before starting to go up to L2.
One thing to quickly reduce the number is tackle errors occurring in traits.
This is becuase phpstan reports errors for each class using the trait, causing lots of duplicates.
With some small and focussed non-intrusive changes, this would lower the baseline already a lot making it easier for further optimalisations of the baseline.
Proposed resolution
I propose to focus on small and simple fixes first which occur a lot in the baseline. Anything which needs a slightly more complex change i would descope.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3325057
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:
- 3325057-fix-phpstan-l2
changes, plain diff MR !11580
Comments
Comment #2
mallezieSome initial work done here.
Attached the update to L2 patch, and patch L2 with small changes. Just checking status. This is not ready yet.
Comment #3
mallezieNew patch.
Comment #4
mallezieBaseline starts here at 9427 errors.
Above patch brings it back to 9298, so that's 130 quick fixes down.
Setting needs review to stop here, and see if we could easily get small things like this committed.
Comment #5
smustgrave commented@mallezie The last patch doesn't pass commit checks, could you make sure to run
./core/scripts/dev/commit-code-check.shbefore uploading a patch to make sure there are no issues with code formatting. see https://www.drupal.org/docs/develop/development-tools/running-core-devel...Fixed the issue.
Comment #6
spokjeTestbot is not a happy bunny...
Comment #7
smustgrave commentedPulled changes for 10.1 this morning but looks like there were more short while ago.
Comment #8
smustgrave commentedThat one I can't explain. Locally it passes.
Comment #9
spokjeAdding parent
Comment #10
spokjeComment #11
spokjeRecreated the PHPStan baseline, let's see what TestBot thinks
Comment #13
spokjeLooks like the changes in the patch break some/quite a lot of tests...
Comment #14
danielvezaI think this is the cause of all the broken tests.
getAccountNamereturns a string, so value isn't needed.I think we should be able to change the return here to WebDriverWebAssert and that should hopefully stop another 500 or so errors being thrown. Specifically the ones with Call to an undefined method Drupal\Tests\WebAssert::{method}
The patch also doesn't apply to 10.1.x anymore, fixed the issues but couldn't get the baseline to regenerate properly. I was getting a lot of new warnings added to the baseline
Comment #15
danielvezaSelf addressed the feedback in #14 and regenerated the baseline. Lets see how the tests go.
Comment #16
smustgrave commentedBelieve I tested this one write
I applied the patch
Changed the level to 2
Staged everything
./core/scripts/dev/commit-code-check.sh --cached
Got no errors.
Let me know if I missed a step for these level 2 stuff.
Comment #17
longwaveShould this be postponed on #3352916: Fix PHPStan L1 errors "Call to method getDefinitions()/getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait.", or should that part of the change here be removed, given it interferes with the fix there?
Comment #18
danielvezaOh good call. Yeah I think we should remove it from this issue. Thats only one part of this patch, so we can just remove it and regenerate the baseline
Comment #20
mably commentedLooks like the problem isn't fixed yet.
Is there a better solution to it other than adding an
@phpstan-ignore-next-line?Comment #23
mstrelan commentedManually applied parts of #15 that weren't already resolved in HEAD and pushed up a new MR. Hiding patches.
Comment #24
danielvezaChanges look good, the only thing I noticed missing from the original patch were the changes to BasicAuthResourceTestTrait::getAuthenticationRequestOptions. Should they be included in this?
Other that that it looks good and is ready to be RTBC, just checking in on that one first.
Comment #25
mstrelan commentedGood spotting, I'm not sure why that one didn't make it initially. I generated the baseline at level 2, then updated that method and regenerated it. This removed a further 96 errors from the baseline, so I think that's worth it.
Comment #26
smustgrave commentedSeems feedback has been addressed.
Comment #28
longwaveThanks, having tried level 2 locally and run into the many duplicated errors caused by traits I think this is worthwhile to clean up now so we can try to get a reasonable baseline before going to level 2 for real.