3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface FooInterface { public function foo(FooInterface $foo); } class Bar implements FooInterface { public function foo(FooInterface $foo): FooInterface { return new self(); } } $bar = new Bar(); $result = $bar->foo(new Bar()); var_dump($result);
based on OpP23
Output for 7.0.0 - 7.2.0
object(Bar)#3 (0) { }
Output for 5.3.19 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/6HPJ5 on line 9
Process exited with code 255.