In PHP is it possible to do something like this:
myFunction( MyClass::staticMethod );
so that \'myFunction\' will have a reference to the stati
Let my try to give a thorough example...
You would make a call like this:
myFunction('Namespace\\MyClass', 'staticMethod');
or like this (if you have arguments you want to pass):
myFunction('Namespace\\MyClass', 'staticMethod', array($arg1, $arg2, $arg3));
And your function to receive this call:
public static function myFunction($class, $method, $args = array())
{
if (is_callable($class, $method)) {
return call_user_func_array(array($class, $method), $args);
}
else {
throw new Exception('Undefined method - ' . $class . '::' . $method);
}
}
Similiar technique is commonly used in the Decorator Pattern in php.