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