I have a class like
class Foo
{
public function runWithCallback($custom_callback) {
...
return call_user_func_array($custom_callback, [$arg_a, $arg_b]);
}
public function aHelperMethod($arg_a) {
...
}
}
And when I use the class like
$foo = new Foo();
$foo->runWithCallback(function($arg_a, $arg_b) {
...
// now I need to use helper method "aHelperMethod"
$this->aHelperMethod($arg_c); // wrong code
...
});
Of course the above code does not work as $this
makes no sense in that anonymous function.
Is it possible to do what I intended to? Thx.