3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bar { public function test() { return "Bar"; } } class BarX extends Bar { public function test() { return "BarX"; } } class A { public function foo(): Bar { //some ops $bar = new Bar; return $bar; //'Bar' object } } class B extends A { public function foo(): Bar { $barX = new BarX; return $barX; //'BarX' object } } $t = new B; echo $t->foo()->test();
based on 54VD0
Output for hhvm-3.15.4, 7.0.0 - 7.2.6
BarX
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/lJaVE on line 16
Process exited with code 255.