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); var_dump($foo); var_dump($bar);
based on HLN7O
Output for 7.0.28 - 7.3.0rc3
object(Foo)#1 (1) { ["a":"Foo":private]=> int(1) } object(Foo)#2 (1) { ["a":"Foo":private]=> int(2) }
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/jNVBt on line 13
Process exited with code 255.