Fatal error: Declaration of Drupal\Component\Plugin\Attribute\AttributeBase::setClass(string $class): void must be compatible with Drupal\Component\Plugin\Definition\PluginDefinitionInterface::setClass($class)

Created on 30 October 2024, about 2 months ago

Problem/Motivation

I'm trying to update the JSON-RPC module to support attributes in addition to annotations.

JSON-RPC annotations extend a custom MethodInterface, which extends core's PluginDefinitionInterface.

This doesn't work with attributes because core's AttributeBase setClass returns void, while PluginDefinitionInterface setClass does not have an explicit return type.

Attempting to use a JsonRpcMethod Attribute that extends MethodInterface results in this fatal error:

Fatal error: Declaration of Drupal\Component\Plugin\Attribute\AttributeBase::setClass(string $class): void must be compatible with Drupal\Component\Plugin\Definition\PluginDefinitionInterface::setClass($class) in

Proposed resolution

I humbly request that core provide a way to have Attributes implement an interface that extends PluginDefinitionInterface.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component

plugin system

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024