First of all, I want to test a function:
private function testMe (array &$output)
{
$output['a'] = 3; // $$$$ $output gets changes
}
I made a little method to make it public, and call:
public static function makePublicAndCall ($objectInstance, $methodname)
{
$ref = new ReflectionMethod (get_class($objectInstance), $methodname);
$ref->setAccessible(true);
$params = array();
for ($i = 2+1; $i <= func_num_args(); $i++)
{
$params[] = func_get_arg($i-1);
}
$result = $ref->invokeArgs ($objectInstance, $params);
for ($i = 2+1; $i <= func_num_args(); $i++)
{
// write back $$$$ here I would need something like "func_get_arg($i-1)"
}
return $result;
}
so, using it:
$output = array();
::makePublicAndCall ($object, 'testMe', $output);
// $output OMG output remains the same! It must not be empty but [a] => 3
see the problem? This method has 2 obligatory parameters, and all others are optional (they go to the invoked method itself). But if those parameters are changed, cannot be carried back!