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 getName() { return $this->name; } public function __toInt() { return 0; } } function f(int $a, C $b) : void { var_dump($a, $b); } $a = new C('a'); $b = new C('b'); f($a, $b);
based on 3GR9s
Output for 7.0.0 - 7.2.6
Fatal error: Uncaught TypeError: Argument 1 passed to f() must be of the type integer, object given, called in /in/WbbHJ on line 28 and defined in /in/WbbHJ:21 Stack trace: #0 /in/WbbHJ(28): f(Object(C), Object(C)) #1 {main} thrown in /in/WbbHJ on line 21
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught TypeError: Argument 1 passed to f() must be an instance of int, C given in /in/WbbHJ:23 Stack trace: #0 /in/WbbHJ(28): f() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/WbbHJ on line 21
Process exited with code 255.