Problem/Motivation
Since Drupal 11.4.0, DeriverInterface::getDerivativeDefinitions() accepts array|PluginDefinitionInterface as the parameter type (https://www.drupal.org/project/drupal/issues/3587110).
In the admin_toolbar_tools module, ExtraLinks::getDerivativeDefinitions() overrides the inherited PHPDoc and declares the parameter type as array<mixed>. This matched the parent definition prior to Drupal 11.4.0, but is no longer compatible with the parent signature starting with Drupal 11.4.0.
This causes issues for static analysis tools such as PHPStan whenever a class extends ExtraLinks and uses {@inheritdoc}. Updating the PHPDoc to match the parent signature results in a PHP fatal error because it conflicts with the parent declaration.
Proposed resolution
- Update the PHPDoc of
ExtraLinks::getDerivativeDefinitions()to use@param array<mixed>|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition. - Add an early return when
$base_plugin_definitionis not anarray. - Create a release compatible with Drupal
^11.4.
Issue fork admin_toolbar-3611568
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:
Comments
Comment #3
johnatas commentedComment #5
liam morlandSince it has
@inheritdoc, it seems to me it shouldn't have@paramor@return. It should be possible to fix this without changingcore_version_requirement. Probably more needs to be done to be compatible with$base_plugin_definitionnot being an array.Comment #6
johnatas commentedIndeed, that makes more sense. I've just pushed a new commit that reverts the
core_version_requirementchanges and keeps only the@inheritdocand theif.Setting this back to Needs work to better handle the case where
$base_plugin_definitionis not an array