I'm trying to call a static magic function (__callStatic) from a member of its child class. Problem being, it goes to the non-static __call instead.
<?php
ini_set("display_errors", true);
class a
{
function __call($method, $params)
{
echo "instance";
}
static function __callStatic($method, $params)
{
echo "static";
}
}
class b extends a
{
function foo()
{
echo static::bar();
// === echo self::bar();
// === echo a::bar();
// === echo b::bar();
}
}
$b = new b();
echo phpversion()."<br />";
$b->foo();
?>
Output:
5.3.6
instance
How can I make it display "static"?
Interestingly, PHP 5.3.3 gives __callStatic priority, but that behavior was reverted back in PHP 5.3.4.$b->foo();. That's not a static function call. The hack would be to do this instead:$b::foo();. Try it for yourself.b::foo();for that matter.