From fe67cad896e720ee4ccdee2f46e289ec8671dbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 13 Aug 2021 17:00:48 +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 --- Annotation/Inject.php | 8 ++------ System/Di/Container.php | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Annotation/Inject.php b/Annotation/Inject.php index 1d8b6fd1..5e15b8aa 100644 --- a/Annotation/Inject.php +++ b/Annotation/Inject.php @@ -5,12 +5,10 @@ namespace Annotation; use Exception; -use HttpServer\Http\Context; use Kiri\Core\Str; use Kiri\Kiri; use ReflectionException; use ReflectionProperty; -use Server\ResponseInterface; /** * Class Inject @@ -94,12 +92,10 @@ use Server\ResponseInterface; */ private function parseInjectValue(): mixed { - if (class_exists($this->value)) { + if (!Kiri::app()->has($this->value)) { return Kiri::getDi()->get($this->value, $this->args); - } else if (Kiri::app()->has($this->value)) { - return Kiri::app()->get($this->value); } else { - return $this->value; + return Kiri::app()->get($this->value); } } diff --git a/System/Di/Container.php b/System/Di/Container.php index 4ceb78d2..297d01bf 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -84,7 +84,7 @@ class Container extends BaseObject */ public function get($class, array $constrict = [], array $config = []): mixed { - if ($this->_isInterface($class)) { + if ($this->isInterface($class)) { $class = $this->_interfaces[$class]; } if (!isset($this->_singletons[$class])) { @@ -99,7 +99,7 @@ class Container extends BaseObject * @return bool * @throws ReflectionException */ - private function _isInterface($class): bool + public function isInterface($class): bool { $reflect = $this->getReflect($class); if ($reflect->isInterface()) {