Possible Duplicate:
Referring to a static member of a subclass
Please have a look at the following code to understand my problem.
<?php
Interface IDoesSomething
{
    public static function returnSomething();
}
abstract class MiddleManClass implements IDoesSomething
{
    public static function doSomething()
    {
        return 1337 * self::returnSomething();
    }
}
class SomeClass extends MiddleManClass
{
    public static function returnSomething()
    {
        return 999;
    }
}
// and now, the vicious call
$foo = SomeClass::doSomething();
/**
 * results in a
 * PHP Fatal error:  Cannot call abstract method IDoesSomething::returnSomething()
 */
?>
Is there a way to force abstraction of returnSomething() while maintaining the possibility to call the function from a function defined in an abstract "middleman" class? Looks like a bottleneck of PHP to me.
If you php version >= 5.3 then change
public static function doSomething()
{
    return 1337 * self::returnSomething();
}
to
public static function doSomething()
{
    return 1337 * static::returnSomething();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With