From 41df45847250f5484fa9f81deddadc23fd7aeb87 Mon Sep 17 00:00:00 2001 From: Vasily Mikhaylovsky Date: Mon, 13 May 2013 09:11:33 +0600 Subject: [PATCH] move Singleton::$_instance into Singleton::getInstance() method --- Singleton/Singleton.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Singleton/Singleton.php b/Singleton/Singleton.php index d7e9bdc..ee896e4 100644 --- a/Singleton/Singleton.php +++ b/Singleton/Singleton.php @@ -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; } /**