Merge pull request #504 from bocharsky-bw/patch-2

Use static property instead of static variable
This commit is contained in:
Phil Sturgeon
2015-06-12 11:41:28 -04:00

View File

@@ -72,21 +72,23 @@ one instance of a particular class. The singleton pattern enables us to do this.
<?php
class Singleton
{
/**
* @var Singleton The reference to *Singleton* instance of this class
*/
private static $instance;
/**
* Returns the *Singleton* instance of this class.
*
* @staticvar Singleton $instance The *Singleton* instances of this class.
*
* @return Singleton The *Singleton* instance.
*/
public static function getInstance()
{
static $instance = null;
if (null === $instance) {
$instance = new static();
if (null === static::$instance) {
static::$instance = new static();
}
return $instance;
return static::$instance;
}
/**