3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { private static function bar($t) { var_dump ($t);} } $ref= (new ReflectionMethod('ReflectionMethod', 'invokeArgs')); $closure = function () use ($ref) { $ref->invokeArgs(new ReflectionMethod('Foo', 'bar'), [1,2]); }; $closure = $closure->bindTo(null, 'Foo'); $closure();
based on ZqXo4
Output for 7.1.0
Fatal error: Uncaught ReflectionException: Trying to invoke private method Foo::bar() from scope ReflectionMethod in /in/fZ2cm:10 Stack trace: #0 [internal function]: ReflectionMethod->invokeArgs(1, 2) #1 /in/fZ2cm(10): ReflectionMethod->invokeArgs(Object(ReflectionMethod), Array) #2 /in/fZ2cm(13): Foo::{closure}() #3 {main} thrown in /in/fZ2cm on line 10
Process exited with code 255.
Output for 5.4.0 - 7.0.14
Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, integer given in /in/fZ2cm on line 10
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/fZ2cm on line 10
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/fZ2cm on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/fZ2cm on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/fZ2cm on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/fZ2cm on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/fZ2cm on line 5
Process exited with code 255.