From 73754f3bfbf7d243f49309216c0a838b5dc0cec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 30 Mar 2023 18:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Container.php | 3 +++ TargetManager.php | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Container.php b/Container.php index fdffa5a..605d695 100644 --- a/Container.php +++ b/Container.php @@ -331,6 +331,9 @@ class Container implements ContainerInterface if (isset($this->_parameters[$className]) && isset($this->_parameters[$className][$method])) { return $this->_parameters[$className][$method]; } + if (!TargetManager::has($className)) { + TargetManager::set($className, $this->getReflect($className)); + } $reflectMethod = $this->getReflectMethod($className, $method); if (!($reflectMethod instanceof ReflectionMethod)) { throw new ReflectionException("Class does not have a function $className::$method"); diff --git a/TargetManager.php b/TargetManager.php index defe451..cfc9674 100644 --- a/TargetManager.php +++ b/TargetManager.php @@ -9,7 +9,6 @@ class TargetManager private static array $targets = []; - /** * @param string $class * @return Target|null @@ -20,6 +19,15 @@ class TargetManager } + /** + * @param string $class + * @return bool + */ + public static function has(string $class): bool + { + return isset(static::$targets[$class]) && static::$targets[$class] !== null; + } + /** * @param string $class * @param \ReflectionClass $reflection