I believe that the callback is implied in the current scope. call_user_func, or any function that uses a callback (for example, preg_replace_callback) is designed to programmatically emulate an equivalent inline call. In other words, it should behave in such a way as to provide the intended functionality.
Therefore, in the following case, Foo->A()they Foo->B()should behave the same, regardless of visibility:
class Foo() {
function Bar() {
}
function A() {
return $this->Bar();
}
function B() {
return call_user_func(array($this, 'Bar'));
}
}
This is clearly not documented, but it would be convenient.
source
share