3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class class2{} class class1{ public function __construct() { } function get_class_2_object() :class2{ return new class2; } } $a = new class1; $b = $a->get_class_2_object(); var_dump($b); ?>
based on vBBuS
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
object(class2)#2 (0) { }
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/2cNv1 on line 6
Process exited with code 255.