From 355c02490b1b37b7b18fa86216f2aa5c1525e956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 25 Apr 2021 12:03:03 +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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/System/Di/Container.php b/System/Di/Container.php index b6534c13..6f09dbea 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -215,6 +215,9 @@ class Container extends BaseObject */ private function resolveDependencies($class): ?array { + if (!isset($this->_constructs[$class])) { + $this->_constructs[$class] = ['class' => $class]; + } if (isset($this->_reflection[$class])) { return [$this->_reflection[$class], $this->_constructs[$class] ?? []]; } @@ -223,15 +226,14 @@ class Container extends BaseObject if (!$reflection->isInstantiable()) { return null; } - $this->scanProperty($reflection); $this->_reflection[$class] = $reflection; - if (!is_null($construct = $reflection->getConstructor())) { - $this->_constructs[$class] = $this->resolveMethodParam($construct); + $this->_constructs[$class] = array_merge($this->_constructs[$class], + $this->resolveMethodParam($construct) + ); } - return [$reflection, $this->_constructs[$class] ?? []]; }