3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait IterableTerminalsLogic { public function single(): true { return true; } } class Collection { use IterableTerminalsLogic; } class Sequence { use IterableTerminalsLogic { single as internalSingle; } #[NoDiscard] public function single(): true { return $this->internalSingle(); } } new Collection()->single(); new Sequence()->single();
Output for 8.4.9 - 8.4.26
Output for 8.2.34, 8.3.0 - 8.3.35
Parse error: syntax error, unexpected token "->" in /in/mFDBn on line 29
Process exited with code 255.
Output for 8.5.8 - 8.5.11
Warning: The return value of method Sequence::single() should either be used or intentionally ignored by casting it as (void) in /in/mFDBn on line 30

preferences:
21.2 ms | 1143 KiB | 11 Q