Fix typehint of ContextDefinition's $label constructor param

Created on 2 August 2024, 6 months ago
Updated 31 August 2024, 5 months ago

Problem/Motivation

PHPStan will complain when passing TranslatableMarkup to a context definition. This is extremely common even in core https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/user/...

Error example:

Parameter #2 $label of class Drupal\Core\Plugin\Context\EntityContextDefinition constructor expects string|null, Drupal\Core\StringTranslation\TranslatableMarkup given.  

Steps to reproduce

Have strict phpstan rules (above 6 probably?)
Create a plugin with a context definition that passes TranslatableMarkup to the label parameter (see above example in core)

Proposed resolution

Accept \Stringeable.

πŸ› Bug report
Status

Fixed

Version

10.3 ✨

Component
BaseΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024