3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class C { private $name; public function __construct(string $name) { $this->name = $name; } public function __toString() { return $this->name; } } function f(string $a, C $b) : void { var_dump($a, $b); } $a = new C('a'); $b = new C('b'); f($a, $b);
based on 4lKFF
Output for 7.1.0 - 7.3.0rc3
string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" }
Output for 7.0.0 - 7.0.20
string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" } Fatal error: Uncaught TypeError: Return value of f() must be an instance of void, none returned in /in/TbjSo:18 Stack trace: #0 /in/TbjSo(23): f('a', Object(C)) #1 {main} thrown in /in/TbjSo on line 18
Process exited with code 255.
Output for hhvm-3.15.4
string(1) "a" object(C)#2 (1) { ["name":"C":private]=> string(1) "b" } Fatal error: Uncaught TypeError: Value returned from function f() must be of type void, null given in /in/TbjSo:18 Stack trace: #0 /in/TbjSo(23): f() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/TbjSo on line 16
Process exited with code 255.