PHP bug report 53081, called
for the warning to be dropped since the addition of the
static::foo()
construct had made abstract static methods reasonable
and useful. Rasmus Lerdorf (creator of PHP) starts off by labelling
the request as bogus and goes through a long chain of bad reasoning to
try to justify the warning. Then, finally, this exchange takes place:
Giorgio
i know, but:
abstract class cA
{
static function A(){static::B();}
abstract static function B();
}
class cB extends cA
{
static function B(){echo "ok";}
}
cB::A();
Rasmus
Right, that is exactly how it should work.
Giorgio
but it is not allowed :(
Rasmus
What's not allowed?
abstract class cA {
static function A(){static::B();}
abstract static function B();
}
class cB extends cA {
static function B(){echo "ok";}
}
cB::A();
This works fine. You obviously can't call self::B(), but static::B()
is fine.
The claim by Rasmus that the code in his example "works fine" is
false; as you know, it throws a strict mode warning. I guess he was
testing without strict mode turned on. Regardless, a confused Rasmus
left the request erroneously closed as "bogus".
And that's why the warning is still in the language. This may not be
an entirely satisfying explanation - you probably came here hoping
there was a rational justification of the warning. Unfortunately, in
the real world, sometimes choices are born from mundane mistakes and
bad reasoning rather than from rational decision-making. This is
simply one of those times.
Luckily, the estimable Nikita Popov has removed the warning from the
language in PHP 7 as part of PHP RFC: Reclassify E_STRICT
notices. Ultimately,
sanity has prevailed, and once PHP 7 is released we can all happily
use abstract static
without receiving this silly warning.