abstract class App_Model_Abstract {
protected static $_instance = null;
protected function __construct() {
}
public static function getInstance() {
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
final private function __clone() {
}
}
você terá problemas, pois ao tentar recuperar uma instância das classes filhas:
ClasseFilha::getInstance();
você estará na verdade recuperando uma instância da classe pai, tirando o fato dela ser abstrata. Para que funcione conforme esperado precisariamos fazer:
abstract class App_Model_Abstract {
protected function __construct() {
}
final public static function getInstance() {
static $aoInstance = array();
$calledClassName = get_called_class();
if (!isset($aoInstance[$calledClassName])) {
$aoInstance[$calledClassName] = new $calledClassName();
}
return $aoInstance[$calledClassName];
}
final private function __clone() {
}
}
Fica a dica!