By andypost on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Description:
The trait is deprecated because since PHP 7.4 exception handling is not required and since PHP 8.0 there's Stringable interface
__toString method must be implemented directly without using \Drupal\Component\Utility\ToStringTrait.
Before:
use \Drupal\Component\Utility\ToStringTrait;
class Example {
use ToStringTrait;
public function render(): string {
return 'Example';
}
}
After:
class Example implements \Stringable {
public function render(): string {
return 'Example';
}
/**
* {@inheritdoc}
*/
public function __toString(): string {
return $this->render();
}
}
Impacts:
Module developers