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
After years I had a moment of serendipity:
class TestClass{
public static function __callStatic($functionName, $arguments) {
$arguments[0]->{'ioParameter'} = 'two';
}
}
$objectWrapper = new StdClass();
$objectWrapper->{'ioParameter'} = 'one';
TestClass::testFunction($objectWrapper);
var_dump($objectWrapper);
// outputs: object(stdClass)#3 (1) { ["ioParameter"]=> string(3) "two" }
(tested on php 5.5)
This workaround is clean and viable if you control the interfaces.
It works by wrapping arguments in an object, which by language definition, is always passed around "by reference".
It allows for passing writable (reference) parameters even using __callStatic (and possibly __call).