3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class Foo{ protected function bar(){ echo 'Foo', PHP_EOL; var_dump($this); return $this; } } class Bar extends Foo{ public function foo(){ echo 'Bar', PHP_EOL; var_dump($this); // this should hold Bar instance and not Foo's $barClassInstance = $this->bar(); var_dump($barClassInstance); } } $bar = new Bar(); $bar->foo();
based on Uj2H8
Output for 5.3.19 - 5.6.38, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.3.0
Bar object(Bar)#1 (0) { } Foo object(Bar)#1 (0) { } object(Bar)#1 (0) { }