Problem/Motivation
I am getting an error in PHPStan when I have provided descriptoin with TranslatableMarkup instead of string:
Parameter $description of class
Drupal\Core\Plugin\Context\ContextDefinition constructor expects
string|null, Drupal\Core\StringTranslation\TranslatableMarkup given.
The offending attribute is defined as below:
context_definitions: [
'entity_id' => new ContextDefinition(
data_type: 'integer',
label: new TranslatableMarkup("Entity ID"),
required: TRUE,
description: new TranslatableMarkup("The ID of the entity to render."),
),
It would be great to allow \Stringable as well as string for this property.
At the same time, we should also update the property type hinting to match the constructor type hinting.
Both label (from prior issue changes) and description(when these changes are implemented) need to have class property updated.
Steps to reproduce
Have strict phpstan rules.
Create a plugin with a context definition that passes TranslatableMarkup to the description parameter
Proposed resolution
1. Update description to have the same typehinting as label - string|null|\Stringable
2. Update property typehinting for label and description to string|null|\Stringable