Problem/Motivation
When adding a new test that uses Drupal\Tests\UpdatePathTestTrait 10 new phpstan errors are thrown for that test because of missing return types. This means the baseline will continue to grow as new tests use this trait.
E.g https://git.drupalcode.org/issue/drupal-3529274/-/jobs/5520794
Steps to reproduce
Add a new test that uses the trait
Proposed resolution
Add return types, tidy up baseline
Remaining tasks
Do it
API changes
Added return types to UpdateTestTrait - should be no BC concerns here.
Issue fork drupal-3529504
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:
- 3529504-10.5.x
changes, plain diff MR !12362
- 3529504-fix-phpstan-errors
changes, plain diff MR !12350
Comments
Comment #3
acbramley commentedComment #4
phenaproximaGet a load of that diffstat! 😍😍😍
Comment #7
xjmGorgeous!
Adding credits for this Slack discussion also, since I took it into account when considering the issue scope:
While I am quite sure there are probably other traits in core missing their
voidreturn typehint, the sheer scope of the baseline reduction here is enough for me to commit this regardless. Saving issue credits.Comment #10
xjmCommitted to 11.x and 11.2.x. Hooray!
We'll want a 10.5.x version of this also, so setting PTBP. Thanks!
Comment #11
xjmI should note that, technically, test traits are considered API, and changing the function signature to add a return typehint (even a
voidreturn typehint) is technically a BC break.However, I stil think this is an acceptable change for the following reasons:
All that said, we shouldn't use this as precedent to commit other return typehint additions to test traits without RM signoff. Test traits were excluded from the scope of #3455548: [meta] Add return typehinting to the test codebase on purpose. So if/when we file followups to add the appropriate
voidtypehints to any test traits, we should make sure that the BC policy and potential disruption are given due consideration before spending 10 min at a time generating new PHPStan baselines and such. :DComment #12
xjmComment #13
xjm#3529510: [meta] Add return types to test traits is the followup (thanks @nicxvan!).
Comment #14
xjmOops.
Comment #17
acbramley commentedThese missing return types don't flag errors currently on 10.5.x so I don't know if it's even worth bothering. I guess if we eventually bump phpstan levels on 10.5 then it would be but that seems unlikely?
Comment #18
nicxvan commentedYeah that's a much smaller diff!
I've reviewed it, I'll mark it if it passes and committers can decide to close this or merge it.
Comment #19
nicxvan commentedComment #20
xjmAhh interesting. So it's not as compelling a 10.5.x backport, BUT given:
That means it's as non-disruptive as a baby bunny in its nest! So, might as well backport for, you know, parity.
d.o, y u uncredit commmitter? Saving. No wonder my clients are making sad faces at me.
Comment #22
xjmAll done!