For example this class:
class A{
public function __call($func, $args){
if($func == 'something')
call_user_func_array($this->_some_magic, $args);
}
public function _some_magic(){
...
}
public static function something(){
...
}
}
Now if I call $a::something() I want the something() method to run (like now).
But if I call $a->something() I want to trigger that undefined method stuff so I can do my magic, not something()…
Is there any way I can detect the way the method was called and execute the method I desire?
ps: I know I could do this using __callstatic and renaming something to something else, but I was wondering if there’s a better solution in which I can keep the current static method name
See
– __call http://www.php.net/manual/en/language.oop5.overloading.php#object.call
– __callStatic http://www.php.net/manual/en/language.oop5.overloading.php#object.callstatic
Or are you talking about determining whether its an external call e.g.:
vs
If its the later case then I’d suggest simply making you internal class calls call another method which the external method call also routes to, e.g.: