优化代码

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 static $instance;
private function __construct()
{
}
/** /**
* 获取单例 * 获取单例
* *
@ -18,15 +22,14 @@ trait StaticInstance
*/ */
static public function getInstance() static public function getInstance()
{ {
if (!(self::$instance instanceof static)) { if (is_null(static::$instance)) {
self::$instance = new static(); static::$instance = new static;
} }
return self::$instance; return static::$instance;
} }
private function __clone() private function __clone()
{ {
} }
} }