3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Baz { protected $data; function __construct($d) { $this->data = $d; } function getData() { return $this->data; } } trait A { public $a; function run() { echo $this->a->getData(); } } class Foo { use A; function __construct() { $this->a = new Baz('Hello '); } } class Bar { use A; function __construct() { $this->a = (new Foo())->a; } } (new Foo)->run(); (new Bar)->run();
based on enIAJ
Output for 5.6.0 - 7.3.0alpha1
Hello Hello