<?php
function userland_call_user_func(callable $function, ...$args) { return $function(...$args); }
class Test {
private function foo() { echo new Exception; }
public function callFoo($callfunc) { $callfunc(array($this, 'foo')); }
}
$o = new Test;
$o->callFoo('call_user_func');
$o->callFoo('userland_call_user_func');
Exception in /in/lNgub:6
Stack trace:
#0 [internal function]: Test->foo()
#1 /in/lNgub(7): call_user_func(Array)
#2 /in/lNgub(11): Test->callFoo('call_user_func')
#3 {main}
Fatal error: Uncaught TypeError: userland_call_user_func(): Argument #1 ($function) must be of type callable, array given, called in /in/lNgub on line 7 and defined in /in/lNgub:3
Stack trace:
#0 /in/lNgub(7): userland_call_user_func(Array)
#1 /in/lNgub(12): Test->callFoo('userland_call_u...')
#2 {main}
thrown in /in/lNgub on line 3
Process exited with code 255.
Exception in /in/lNgub:6
Stack trace:
#0 [internal function]: Test->foo()
#1 /in/lNgub(7): call_user_func(Array)
#2 /in/lNgub(11): Test->callFoo('call_user_func')
#3 {main}
Fatal error: Uncaught TypeError: Argument 1 passed to userland_call_user_func() must be callable, array given, called in /in/lNgub on line 7 and defined in /in/lNgub:3
Stack trace:
#0 /in/lNgub(7): userland_call_user_func(Array)
#1 /in/lNgub(12): Test->callFoo('userland_call_u...')
#2 {main}
thrown in /in/lNgub on line 3
Process exited with code 255.
Output for 5.6.0 - 5.6.25
exception 'Exception' in /in/lNgub:6
Stack trace:
#0 [internal function]: Test->foo()
#1 /in/lNgub(7): call_user_func(Array)
#2 /in/lNgub(11): Test->callFoo('call_user_func')
#3 {main}
Catchable fatal error: Argument 1 passed to userland_call_user_func() must be callable, array given, called in /in/lNgub on line 7 and defined in /in/lNgub on line 3
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/lNgub on line 3
Process exited with code 255.