From c99b294eddc5927e8d7b782109ea82df75240f9e Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Sun, 30 May 2021 18:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Traits/StaticInstance.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Traits/StaticInstance.php b/app/Traits/StaticInstance.php index e0aea86..872b30e 100644 --- a/app/Traits/StaticInstance.php +++ b/app/Traits/StaticInstance.php @@ -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() { - } }