mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
move Singleton::$_instance into Singleton::getInstance() method
This commit is contained in:
parent
cd2183b2a2
commit
41df458472
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user