diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 4033e9fd..bd18b401 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -122,10 +122,9 @@ class Annotation extends Component if (empty($reflect)) { return []; } - if (!$reflect->isInstantiable()) { - return $this->targets($reflect); - } - $object = $reflect->newInstance(); + $depend = Snowflake::getDi()->getDependencies($class); + + $object = $reflect->newInstanceArgs($depend); $this->resolveMethod($reflect, $class, $alias, $object); return $this->targets($reflect); } diff --git a/System/Di/Container.php b/System/Di/Container.php index f74d8b37..85e47184 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -192,6 +192,16 @@ class Container extends BaseObject } + /** + * @param $class + * @return mixed + */ + public function getDependencies($class): mixed + { + return $this->_constructs[$class] ?? []; + } + + /** * @param $class * @return ReflectionClass|null