You need to do this:
class AppBaseSessionRegistryTwo extends BaseSessionRegistry { protected static $_instance = NULL;
If you do not declare the static property separately, they will use the same static property of their parent.
Update: If you do not want the children to declare a static property, you can declare the static property as an array of the parent element.
abstract class Singleton { protected static $_instances = array(); // ... /** * Returns new or existing Singleton instance * @return Singleton */ final public static function getInstance(){ $class_name = get_called_class(); if(isset(self::$_instances[$class_name])){ return self::$_instances[$class_name]; } return self::$_instances[$class_name] = new static(); } abstract protected function actionBeforeInstantiate(); }
xdazz
source share