LoopRun Barcelona 2020


(PHP 5 >= 5.1.2, PHP 7)

ReflectionFunction::invokeArgsİşlev değiştirgelerini çağırır


public ReflectionFunction::invokeArgs ( array $değiştirgeler ) : mixed

İşlev değiştirgelerini çağırır.


Bu işlev hala belgelendirilmemiştir; sadece değiştirge listesi mevcuttur.



Çağrılacak değiştirgeler.

Dönen Değerler

Ayrıca Bakınız

add a note add a note

User Contributed Notes 2 notes

theyourcomputer at gmail dot com
2 years ago
In the case of call_user_func_array(), if you were to pass around an anonymous function and reference $this within the anonymous function, $this will faithfully refer to the class in the context in which the function was defined. Using ReflectionFunction::invokeArgs() does not seem to retain its original context--yeah, even if you bind the anonymous function before invoking. I recommend call_user_func_array() where context is a concern.
Andrea Giammarchi
12 years ago
I encountered a weird problem with ReflectionFunction, described in ticket 44139 of PHP Bugs.

If for some reason you need to call with invoke, or invokeArgs, a function like array_unshift (that accepts internally the array by reference) you could use this code to avoid the generated warning or fatal error.

function unshift(){
$ref        = new ReflectionFunction('array_unshift');
$arguments    = func_get_args();
$ref->invokeArgs(array_merge(array(&$this->arr), $arguments));

I don't know about performances (you can create an array manually too, starting from array(&$this->something) and adding arguments). However, it seems to work correctly without problems, at least until the send by reference will be usable with one single value ...
To Top