I\'ve been reading around on SO, and elsewhere, however I can\'t seem to find anything conclusive.
Is there any way to effectively carry references through this call
Wow, after more than hour of blowing my mind, I'm still not sure but...
mixed call_user_func_array ( callback $function , array $param_arr )
If we use simple logic (in this situation) when class calls function call_user_func_array()
it uses static strings as parameters (passed by magic method __callStatic()
), so parameter 2 is a string in eyes of call_user_func_array()
function and that parameter is also parameter 1 for function testFunction()
. It's simply string not a pointer to variable, and that probably is a reason for message like:
Warning: Parameter 1 to testFunction() expected to be a reference, value given in ... on line ...
In other words, it just can't assign value back to variable that doesn't exist but still, testFunction() expects parameter to be a reference and throws warning because it's not.
You can test it out of class like:
function testFunction(&$arg){
$arg .= 'world';
}
$string = 'hello';
call_user_func_array('testFunction', array($string));
echo $string;
It throws same Warning! So problem is not with class, problem is this function.
This function obviously passes function parameters as static data without pointing to variables and functions it calls just can not handle referenced arguments.