优化代码

main
gzydong 2021-05-30 18:03:44 +08:00
parent 4630ed8397
commit c99b294edd
1 changed files with 7 additions and 4 deletions

View File

@ -11,6 +11,10 @@ trait StaticInstance
{
private static $instance;
private function __construct()
{
}
/**
* 获取单例
*
@ -18,15 +22,14 @@ trait StaticInstance
*/
static public function getInstance()
{
if (!(self::$instance instanceof static)) {
self::$instance = new static();
if (is_null(static::$instance)) {
static::$instance = new static;
}
return self::$instance;
return static::$instance;
}
private function __clone()
{
}
}