Problem/Motivation
As of #2852656, plugins can have object-based definitions. However the typing in the docblocks is set only to array for the $pluginDefinition
property of core/lib/Drupal/Component/Plugin/PluginBase.php
and the return value of getPluginDefinition
in core/lib/Drupal/Component/Plugin/PluginInspectionInterface.php
.
Proposed resolution
These docblocks should be updated from array
to \Drupal\Component\Plugin\Definition\PluginDefinitionInterface|array
.
Issue fork drupal-3417521
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:
- 3417521-update-plugin-typing changes, plain diff MR !6341
Comments
Comment #2
jayhuskinsComment #4
jayhuskinsComment #5
smustgrave CreditAttribution: smustgrave at Mobomo commentedReading CR, believe the update is correct.
Comment #6
quietone CreditAttribution: quietone at PreviousNext commentedI'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions or other work to do.
Leaving at RTBC.
Comment #7
longwaveBackported as a docs-only improvement.
Committed and pushed ed6f70f8b8 to 11.x and c3ceee3d74 to 10.3.x and 2a7b91d0d4 to 10.2.x. Thanks!
Comment #12
mikeryanWe're having CI failures on our app with Drupal 10.2.4, which passes under Drupal 10.2.3, and this appears to be the relevant change.
The triggering code:
This should still be correct usage, shouldn't it? Core is still full of instances of
$this->pluginDefinition['key']
.Comment #13
mstrelan CreditAttribution: mstrelan at PreviousNext commented@mikeryan you likely have a higher phpstan level than core. I think you might need to change to something like this:
Or coerce phpstan in to believing pluginDefinition is always an array:
Edit:
Or you could probably override the typehint on the property in your plugin class:
Comment #14
mikeryan@mstrelan Thanks!
assert()
did the job nicely...