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_definition is not an array.
  • Create a release compatible with Drupal ^11.4.
Command icon 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

johnatas created an issue. See original summary.

johnatas’s picture

Status: Active » Needs review

dydave made their first commit to this issue’s fork.

liam morland’s picture

Since it has @inheritdoc, it seems to me it shouldn't have @param or @return. It should be possible to fix this without changing core_version_requirement. Probably more needs to be done to be compatible with $base_plugin_definition not being an array.

johnatas’s picture

Status: Needs review » Needs work

Indeed, that makes more sense. I've just pushed a new commit that reverts the core_version_requirement changes and keeps only the @inheritdoc and the if.

Setting this back to Needs work to better handle the case where $base_plugin_definition is not an array