From e3fedc42ec3ba2eb3d84ff00936995859bbf14ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 22 Feb 2021 19:26:39 +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 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/System/Di/Container.php b/System/Di/Container.php index 736e22cc..36619a4c 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace Snowflake\Di; +use Exception; use ReflectionClass; use Snowflake\Abstracts\BaseObject; use ReflectionException; @@ -125,6 +126,7 @@ class Container extends BaseObject * @return object * @throws NotFindClassException * @throws ReflectionException + * @throws Exception */ private function resolve($class, $constrict, $config): object { @@ -133,7 +135,7 @@ class Container extends BaseObject $dependencies[$index] = $param; } if (!$reflect->isInstantiable()) { - throw new NotFindClassException($reflect->getName()); + throw new Exception($reflect->getName() . ' con\'t instantiable'); } if (empty($config)) { return $reflect->newInstanceArgs($dependencies ?? []); @@ -168,16 +170,11 @@ class Container extends BaseObject }; $constructs = $reflection->getConstructor(); if (!($constructs instanceof \ReflectionMethod)) { - return [ - $reflection, $this->_constructs[$class] = [ - 'class' => $class - ] - ]; + return [$reflection, $this->_constructs[$class] = []]; } foreach ($constructs->getParameters() as $key => $param) { $dependencies[] = $this->resolveDefaultValue($param); } - $dependencies['class'] = $class; $this->_constructs[$class] = $dependencies; return [$reflection, $dependencies]; }