note 46680 deleted from language.oop5.reflection by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Sep 2009 16:19:29 +0000 |
| Subject: | note 46680 deleted from language.oop5.reflection by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160726@lists.php.net to get a copy of this message | ||
Note Submitter: russ dot collier at gmail dot com
----
Actually, aside from my inconsistent order of keywords in the 2 factory methods ;-) the
Triangle::getInstance() method has 1 glaring flaw: it never actually sets the Triangle::$instance
property. The correct way to implement a Singleton this way would be to replace
Triangle::getInstance() with this:
<?php
static public function getInstance()
{
if ( null == self::$instance )
{
self::$instance = new self;
return self::$instance;
}
return self::$instance;
}
?>