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 @param of ExtraLinks::getDerivativeDefinitions() to array<mixed>|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition, like the parent.
  • The explicit @param and @return are kept after {@inheritdoc}: with only {@inheritdoc}, PHPStan (level 6) reports missingType.iterableValue for the parameter and the return type, since the inherited types are array without 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_definition is not an array was considered, but is not needed: ExtraLinks is only used as the deriver of 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

  1. Run PHPStan on the module: no error is reported for ExtraLinks.php.
  2. Run the admin_toolbar_tools tests: no change.
Edited by David Suissa

Merge request reports

Loading
Loading