3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { protected $bar; public function __construct(BarInterface $bar) { $this->bar = $bar; } public function doAction() { echo $this->bar->getVar(); } } interface BarInterface { public function getVar(); } abstract class BarAbstract implements BarInterface { public function getVar() { return $this->var; } } class Bar extends BarAbstract { protected $var = __CLASS__; } class Baz extends BarAbstract { protected $var = __CLASS__; } $bar = new Bar(); $foo = new Foo($bar); $foo->doAction();
based on JVA6P
Output for 5.3.19 - 7.2.0
Bar