move Singleton::$_instance into Singleton::getInstance() method

This commit is contained in:
Vasily Mikhaylovsky 2013-05-13 09:11:33 +06:00
parent cd2183b2a2
commit 41df458472

View File

@ -16,11 +16,6 @@ namespace DesignPatterns;
*/
class Singleton
{
/**
* @var \DesignPatterns\Singleton
*/
private static $_instance;
/**
* gets the instance via lazy initialization (created on first usage)
*
@ -28,11 +23,13 @@ class Singleton
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
static $instance;
if (null === $instance) {
$instance = new self();
}
return self::$_instance;
return $instance;
}
/**