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
This is a fun one.
TestClass::testFunction(&$string);
This works, but it also throws a call-time-pass-by-reference warning.
The main issue is that __callStatic
's second argument comes in by value. It's creating a copy of the data, unless that data is already a reference.
We can duplicate the calling error thusly:
call_user_func_array('testFunction', array( $string ));
// PHP Warning: Parameter 1 to testFunction() expected to be a reference, value given
call_user_func_array('testFunction', array( &$string ));
echo $string;
// 'helloworld'
I tried to modify the __callStatic
method to copy the array deeply by reference, but that didn't work either.
I'm pretty sure that the immediate copy caused by __callStatic
is going to be a killer here, and that you won't be able to do this without enough hoop jumping to make it a bit sticker, syntax-wise.