3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { static function bar($a) { echo $a; } } $r = new ReflectionClass('foo'); $m = $r->getMethod('bar'); $m->invokeArgs('some_other_class_name', ['baz']); $m->invokeArgs(42, ['baz']); $m->invokeArgs(new DateTime, ['baz']); $m->invokeArgs($r, ['baz']);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
Fatal error: Uncaught TypeError: ReflectionMethod::invokeArgs(): Argument #1 ($object) must be of type ?object, string given in /in/n8cad:13 Stack trace: #0 /in/n8cad(13): ReflectionMethod->invokeArgs('some_other_clas...', Array) #1 {main} thrown in /in/n8cad on line 13
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, string given in /in/n8cad on line 13 Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, int given in /in/n8cad on line 14 bazbaz
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, string given in /in/n8cad on line 13 Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, integer given in /in/n8cad on line 14 bazbaz

preferences:
76.05 ms | 410 KiB | 5 Q