I am developing a custom ORM and here is a simplified example to demonstrate the problem:
class Foo {
public static function __callStatic($name, $args){
if($name == "getBar"){
return "Bar";
}
return NULL;
}
public function __call($name, $args){
if($name == "getFoo"){
$model = "Foo";
$method = "getBar";
return $model::$method();
}
return NULL;
}
}
class Foo2 {
public function __call($name, $args){
if($name == "getFoo"){
$model = "Foo";
$method = "getBar";
return $model::$method();
}
return NULL;
}
}
echo Foo::getBar();
$foo = new Foo;
var_dump($foo->getFoo());
$foo = new Foo2;
var_dump($foo->getFoo());
So, why is the method called inside Foo triggers __calland inside Foo2triggers __callStatic?
source
share