3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $a; public function __construct(int $a) { $this->a = $a; } public function __invoke(int $a) : Bar { return new Bar($a); } } class Bar { private $a; public function __construct(int $a) { $this->a = $a; } } $foo = new Foo(1); $bar = new $foo(2); $bar2 = new ($foo(2)); var_dump($foo); var_dump($bar); var_dump($bar2);
based on brcPH
Output for 7.0.28 - 7.3.0rc3
Parse error: syntax error, unexpected '(' in /in/Wh8nD on line 35
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/Wh8nD on line 13
Process exited with code 255.