I have the "foundations" of a web site that can be extended to create specific applications. In my core features I have an abstract class C_Controller which has to be a singleton. In order to create a specific application using the core features, a developer has to extend this C_Controller class. This class (let's name it C_Application) also has to be a singleton. In order to force the developer to implement his own getInstance method, I've done the following :
interface I_Singleton
{
public static function getInstance();
}
abstract class C_Controller implements I_Singleton
{
public abstract static function getInstance();
}
Then the developer would have to implement the function in his sub class:
class C_Application extends C_Controller
{
public static function getInstance() { ... }
}
I've already been doing this for my views, but it was a non-static method (__toString). I've read that it's not possible to have abstract static methods since PHP 5.2, so is there a clean way to do that?
I'm limited to PHP 5.2. due to the free web hosting service I'm using.
Thanks for your help!