Loading
Issue #3611568: Update the getDerivativeDefinitions() docblock of ExtraLinks to match DeriverInterface
https://www.drupal.org/project/admin_toolbar/issues/3611568
Problem
Since Drupal 11.4.0 (core issue #3587110), the docblock of DeriverInterface::getDerivativeDefinitions() declares the parameter as array|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface.
ExtraLinks::getDerivativeDefinitions() documents the parameter as array<mixed> only. This is narrower than the parent, which static analysis tools (PHPStan) can report, in particular for classes extending ExtraLinks that use {@inheritdoc}.
Changes
- Updated the
@paramofExtraLinks::getDerivativeDefinitions()toarray<mixed>|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition, like the parent. - The explicit
@paramand@returnare kept after{@inheritdoc}: with only{@inheritdoc}, PHPStan (level 6) reportsmissingType.iterableValuefor the parameter and the return type, since the inherited types arearraywithout a value type. - No change in the behavior or the native signature, and no change to the
core_version_requirement.
Notes
- An early return when
$base_plugin_definitionis not an array was considered, but is not needed:ExtraLinksis only used as thederiverof a YAML menu link (admin_toolbar_tools.links.menu.yml), and the YAML discovery always passes the base definition as an array. PHPStan passes without it.
How to test
- Run PHPStan on the module: no error is reported for
ExtraLinks.php. - Run the
admin_toolbar_toolstests: no change.
Edited by David Suissa