I need a class that would let the user take advantage of both normal (non-static) methods and static methods. The actual implementation would reside in the static methods, which would be called by virtual non-static methods of the same name via the magic __call
method. The problem however is that, when calling a non-static method in this way, PHP thinks that the programmer made a mistake and the static method was actually meant to be called:
class AClass
{
public static function method ()
{
// implementation
}
public function __call ($name, $arguments)
{
var_dump("Hello");
call_user_func_array("AClass::$name", $arguments);
}
}
$obj = new AClass;
$obj->method();
So "Hello" is no being output when invoking method
method on the object but is being output if trying to invoke a method with any other name. Any way to achieve the correct behavior while preserving method naming?