- Issue created by @jayhuskins
- Merge request !6341Type $pluginDefinition as array or PluginDefinitionInterface β (Closed) created by jayhuskins
- Status changed to Needs review
10 months ago 5:58pm 27 January 2024 - Status changed to RTBC
10 months ago 4:07pm 2 February 2024 - πΊπΈUnited States smustgrave
Reading CR, believe the update is correct.
- π³πΏNew Zealand quietone
I'm triaging RTBC issues β . I read the IS and the comments. I didn't find any unanswered questions or other work to do.
Leaving at RTBC.
- π¬π§United Kingdom longwave UK
Backported as a docs-only improvement.
Committed and pushed ed6f70f8b8 to 11.x and c3ceee3d74 to 10.3.x and 2a7b91d0d4 to 10.2.x. Thanks!
-
longwave β
committed 2a7b91d0 on 10.2.x
Issue #3417521 by jayhuskins: Update typing for plugin definition to...
-
longwave β
committed 2a7b91d0 on 10.2.x
-
longwave β
committed c3ceee3d on 10.3.x
Issue #3417521 by jayhuskins: Update typing for plugin definition to...
-
longwave β
committed c3ceee3d on 10.3.x
- Status changed to Fixed
9 months ago 3:31pm 4 March 2024 -
longwave β
committed ed6f70f8 on 11.x
Issue #3417521 by jayhuskins: Update typing for plugin definition to...
-
longwave β
committed ed6f70f8 on 11.x
- πΊπΈUnited States mikeryan Murphysboro, IL, USA
We're having CI failures on our app with Drupal 10.2.4, which passes under Drupal 10.2.3, and this appears to be the relevant change.
Error: Cannot access offset 'id' on array|Drupal\Component\Plugin\Definition\PluginDefinitionInterface. ------ --------------------------------------------------------------------- Line src/ActiveSitePluginBase.php ------ --------------------------------------------------------------------- 54 Cannot access offset 'id' on array|Drupal\Component\Plugin\Definition\PluginDefinitionInterface. ------ ---------------------------------------------------------------------
The triggering code:
/** * {@inheritdoc} */ public function id(): string { return $this->pluginDefinition['id']; }
This should still be correct usage, shouldn't it? Core is still full of instances of
$this->pluginDefinition['key']
. - π¦πΊAustralia mstrelan
@mikeryan you likely have a higher phpstan level than core. I think you might need to change to something like this:
public function id(): string { if (is_array($this->pluginDefinition)) { return $this->pluginDefinition['id']; } return $this->pluginDefinition->id(); }
Or coerce phpstan in to believing pluginDefinition is always an array:
public function id(): string { assert(is_array($this->pluginDefinition)); return $this->pluginDefinition['id']; }
- πΊπΈUnited States mikeryan Murphysboro, IL, USA
@mstrelan Thanks!
assert()
did the job nicely... Automatically closed - issue fixed for 2 weeks with no activity.