Calling a public, static function in an abstract class Calling a public, static function in an abstract class php php

Calling a public, static function in an abstract class


Static methods in OOP do not change internal state, therefore you can call static methods from an abstract class.


I would be surprised if this wouldn't be allowed. Abstract class assumes you cannot instantiate it. As static methods don't need a class instance, you can happily use them.

Looking deeper, you could create an abstract static method and call it from your non-abstract method:

abstract class ScopeFactory{    public static function doStuff()    {        static::otherStuff();    }    abstract public static function otherStuff();}

PHP will give you a fatal error saying you cannot call an abstract method. But also it'll give you a E_STRICT warning saying you shouldn't create abstract static methods.