Problem/Motivation
Amongst the current suppressions found in the PHPStan level 1 baseline are: Call to method getDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait. and Call to method getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait..
This issue exists to fix all of those.
Steps to reproduce
- Run PHPStan on level 1 and see the above issue amongst all others.
Proposed resolution
- Solve all of the reported issues for the above mentioned.
- Run PHPStan on level 1 and don't see the above issue any more.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3352916
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:
- 3352916-alternative
changes, plain diff MR !10468
- 3352916-fix-phpstan-l1
changes, plain diff MR !3794
Comments
Comment #3
spokjeComment #5
spokjeComment #6
mondrakeLeft a comment in the MR. Can you help me understand @Spokje?
Comment #7
spokje@mondrake: Tried a (weak) explanation in the MR thread.
Comment #8
mondrakeComment in MR, thanks!
Comment #9
spokje@mondrake Makes sense, will change it shortly.
If it turns out to be too much we can always revert to the "minimal" working cas at https://git.drupalcode.org/project/drupal/-/merge_requests/3794/diffs?co...
Comment #10
spokjeComment #11
mondrakeBTW: is the issue title still accurate?
Comment #12
spokjeYou're right, we can be more specific here.
Comment #13
spokjeComment #14
spokjeOk, let's give this a new NR round :)
Comment #15
mondrakeTo me, this is the cleanest way to fix this mess…
Comment #16
longwaveAdding an argument to the interface is not backward compatible with any existing implementations, and there are a handful in contrib at least:
http://grep.xnddx.ru/search?text=getSortedDefinitions&filename=
Comment #17
mondrakeI have opened #3354524: Document how to add additional parameters to interface methods to discuss how to manage cases where interfaces are wrong and we cannot change them
Comment #18
spokjeAnd another PHPStan issue grinds to a halt, postponing on #3354524: Document how to add additional parameters to interface methods
Comment #19
mondrakeLooking for #3236391: (outdated) Replace func_get_args with variable-length argument in FormBuilder to go in, that sets a reference for prepping the addition of arguments to interface methods, and this could follow.
Comment #20
mondrakeComment #21
mondrakeTypehinting of return type follows the covariance rules https://www.php.net/manual/en/language.oop5.variance.php, so adding one to the interface means BC break because implementing classes must at least implement the same return type.
Comment #22
mondrakeComment #23
mondrakeComment #25
bbralaHow to change signatures in interfaces has been documented: #3354524: Document how to add additional parameters to interface methods
Comment #27
longwaveTraits can have abstract methods, if we do that we can remove the @var and it seems happy enough? See MR!10468.
Comment #28
smustgrave commentedNice! I was not aware of the abstract methods approach but will be remembering it. Change appears pretty straight forward and addresses the task. LGTM
Comment #29
larowlanCommitted to 11.x thanks!