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