3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait MarkupTrait { /** * The safe string. * * @var string */ protected $string; /** * Creates a Markup object if necessary. * * If $string is equal to a blank string then it is not necessary to create a * Markup object. If $string is an object that implements MarkupInterface it * is returned unchanged. * * @param mixed $string * The string to mark as safe. This value will be cast to a string. * * @return string|\Drupal\Component\Render\MarkupInterface * A safe string. */ public static function create($string) { if ($string instanceof MarkupInterface) { return $string; } $string = (string) $string; if ($string === '') { return ''; } $safe_string = new static(); $safe_string->string = $string; return $safe_string; } } $markup = MarkupTrait::create('foo');
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Deprecated: Calling static trait method MarkupTrait::create is deprecated, it should only be called on a class using the trait in /in/CpIhN on line 39 Fatal error: Uncaught Error: Cannot instantiate trait MarkupTrait in /in/CpIhN:33 Stack trace: #0 /in/CpIhN(39): MarkupTrait::create('foo') #1 {main} thrown in /in/CpIhN on line 33
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Fatal error: Uncaught Error: Cannot instantiate trait MarkupTrait in /in/CpIhN:33 Stack trace: #0 /in/CpIhN(39): MarkupTrait::create('foo') #1 {main} thrown in /in/CpIhN on line 33
Process exited with code 255.
Output for 5.6.0 - 5.6.24
Fatal error: Cannot instantiate trait MarkupTrait in /in/CpIhN on line 33
Process exited with code 255.

preferences:
144.39 ms | 408 KiB | 5 Q