title: Extend abstract singleton class
body: <p>If you had a factory class that creates new objects of some kind, and that factroy class is a singleton, like this:</p>
  
  <pre><code>class Database_Factory extends Base_Factory {
      private static $factory;
      private $objects = array();
  
      public function __get($profile) {
          // check for object and return it if it's created before
      }
  
      public static function getInstance(){
          if (!self::$factory)
              self::$factory = new self();
          return self::$factory;
      }
  }
  </code></pre>
  
  <p>The same code repeats anytime where some object needs it's own factory. So i decided to make this factory class abstract and implement only specific routines for each factory. But PHP does not allow to instantiate abstract class.</p>
  
  <pre><code>abstract class Base_Factory {
      public static function getInstance(){
          if (!self::$factory)
              self::$factory = new self();
          return self::$factory;
      }
  }
  </code></pre>
  
  <p>Fatal error: Cannot instantiate abstract class Base_Factory</p>
  
  <p>What would you do?</p>