3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { use TFoo; function test() { var_dump(__METHOD__); $this->getFromTrait(); } } class Bar { public function __construct($a) { } function some() { die(__METHOD__); } } trait TFoo { function getFromTrait() { return new Bar($this->getSomething()); } function getSomething() { // Must be called!!! die(__METHOD__); } } (new Foo())->test();

preferences:
61.08 ms | 402 KiB | 5 Q