MarkupInterface should extend \Stringable

Created on 17 December 2021, over 2 years ago
Updated 13 February 2023, over 1 year ago

PHP 8.0.0 adds the \Stringable interface, which assures the existence of the __toString magic method on any class that implements it. If MarkupInterface were to extend it, this would mark all Markup objects as being safely castable to string, allowing Drupal-independent code to accept/return it anywhere string|\Stringable is type-hinted.

Arguments for making this change in a D9 minor version:

- Even though Drupal 9 does not yet require PHP 8, we already have access to \Stringable via the symfony/polyfill-php80 package
- \Stringable is exactly equivalent to MarkupInterface in that both only contain the __toString() method, so extending it doesn't alter any contracts or break BC.

πŸ“Œ Task
Status

Fixed

Version

10.1 ✨

Component
RenderΒ  β†’

Last updated 2 days ago

Created by

πŸ‡¨πŸ‡­Switzerland cburschka

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024