mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-12 10:56:22 +02:00
move Singleton::$_instance into Singleton::getInstance() method
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user