3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); namespace funcs { function int(int ...$ints) {} } namespace { function sum(array $ints): int { (funcs\int)(...$ints); return array_sum($ints); } var_dump(sum([1, 2, 3])); var_dump(sum([1, 2, "three"])); }
based on 8YoZN
Output for 7.0.30 - 7.3.0alpha1
Fatal error: Uncaught Error: Undefined constant 'funcs\int' in /in/r7DKc:13 Stack trace: #0 /in/r7DKc(18): sum(Array) #1 {main} thrown in /in/r7DKc on line 13
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Parameter $ints is variadic and has a type constraint (HH\int); variadic params with type constraints are not supported in non-Hack files in /in/r7DKc:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Parameter $ints is variadic and has a type constraint (HH\int); variadic params with type constraints are not supported in non-Hack files in /in/r7DKc:6 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Warning: Unsupported declare 'strict_types' in /in/r7DKc on line 2 Parse error: syntax error, unexpected ':', expecting '{' in /in/r7DKc on line 12
Process exited with code 255.