I have a complicated scenario based on an existing framework I'm using which is forcing me to deal with nested call_user_func_array
calls. I've got a file with two functions:
function their_caller($options)
{
call_user_func_array('their_callback', $options);
}
function their_callback($options)
{
call_user_func_array($options[0], $options[1]);
}
Then I have another file with a class with and some public methods:
namespace FOO;
class MyClass
{
public function my_caller()
{
$operations = array(
array(
array($this, 'my_callback'),
'Hello World'
)
);
their_caller($operations);
}
public function my_callback($text)
{
print $text;
}
}
When I call my_caller()
on a new instance of MyClass
, it calls their_caller
which then passes an array of arguments containing a reference to MyClass
(as $this
) as well as the method my_callback
.
their_caller()
then forwards the request to their_callback
and passes $options
along.
In their_callback
I can debug $options[0]
and see that it's an array containing a reference to MyClass
and my_callback
.
I call get_class_methods()
on $options[0][0]
in their_callback
and it will show the list of methods, but for some reason, call_user_func_array($options[0], $options[1]);
won't call my_callback
on MyClass
. I can even call $options[0][0]->my_callback('HELLO');
and it works.
Unfortunately, I can't modify their_caller
or their_callback
. They are part of the framework. Any ideas what's preventing it from working?