From 1b2504883f897b4f8248a7506e44028f7cf426a4 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 23 Feb 2021 01:44:40 +0800 Subject: [PATCH] modify --- System/Di/Container.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/System/Di/Container.php b/System/Di/Container.php index a56acea9..bda0bf19 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -95,20 +95,19 @@ class Container extends BaseObject if (!$reflect->isInstantiable()) { throw new NotFindClassException($reflect->getName()); } - if (empty($config)) { - return $reflect->newInstanceArgs($dependencies ?? []); - } - $dependencies = $this->_constructs[$class] ?? null; + $dependencies = $this->_constructs[$class] ?? []; + if (empty($config)) { + return $reflect->newInstanceArgs($dependencies); + } + $this->_param[$class] = $config; + if (!empty($dependencies) && $reflect->implementsInterface('Snowflake\Abstracts\Configure')) { $dependencies[count($dependencies) - 1] = $config; return $reflect->newInstanceArgs($dependencies); } - $this->_param[$class] = $config; - $object = !is_null($dependencies) ? $reflect->newInstanceArgs($dependencies) : $reflect->newInstance(); - - return $this->onAfterInit($object, $config); + return $this->onAfterInit($reflect->newInstanceArgs($dependencies), $config); } /**