mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-21 16:52:49 +02:00
Self static accessor
Inside a final class or anonymous class self should be preferred to static.
This commit is contained in:
@ -15,11 +15,11 @@ final class Singleton
|
|||||||
*/
|
*/
|
||||||
public static function getInstance(): Singleton
|
public static function getInstance(): Singleton
|
||||||
{
|
{
|
||||||
if (static::$instance === null) {
|
if (self::$instance === null) {
|
||||||
static::$instance = new static();
|
self::$instance = new self();
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user