3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: ReflectionMethod::invokeArgs(): Argument #1 ($object) must be of type ?object, int given 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 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
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 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
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.1.6, 5.2.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.3.11, 4.4.0 - 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.

preferences:
258.44 ms | 401 KiB | 356 Q