From 3b0e0a504f25ffbfa1d1ca8ee7330c04d2dd5c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 25 Apr 2021 15:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Di/Container.php | 2 +- System/Di/Service.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/System/Di/Container.php b/System/Di/Container.php index ccea0a80..9b04b214 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -71,7 +71,7 @@ class Container extends BaseObject public function get($class, $constrict = [], $config = []): mixed { if (isset($this->_singletons[$class])) { - return $this->_singletons[$class]; + return clone $this->_singletons[$class]; } else if (!isset($this->_constructs[$class])) { return $this->resolve($class, $constrict, $config); } diff --git a/System/Di/Service.php b/System/Di/Service.php index 1f2b475c..2f2fe416 100644 --- a/System/Di/Service.php +++ b/System/Di/Service.php @@ -54,11 +54,11 @@ class Service extends Component if (is_object($config)) { return $this->_components[$id] = $config; } - $object = clone Snowflake::createObject($config); + $object = Snowflake::createObject($config); } else { $config = $this->_alias[$id]; - $object = clone Snowflake::createObject($config); + $object = Snowflake::createObject($config); } return $this->_components[$id] = $object; }