This commit is contained in:
2023-04-16 16:58:34 +08:00
parent 9c67fb556f
commit edfe966e83
+12 -1
View File
@@ -168,13 +168,24 @@ class Container implements ContainerInterface
$object = self::configure($reflect->newInstanceArgs($construct), $config);
return $this->inject($object, $reflect);
}
/**
* @param object $object
* @param ReflectionClass $reflect
* @return object
*/
private function inject(object $object, ReflectionClass $reflect): object
{
$targetAttributes = $reflect->getAttributes();
foreach ($targetAttributes as $attribute) {
$attribute->newInstance()->dispatch($object);
}
$this->resolveProperties($reflect, $object);
if (method_exists($object, 'init') && $className !== 'Symfony\Component\Console\Application') {
if (method_exists($object, 'init') && $object::class !== 'Symfony\Component\Console\Application') {
call_user_func([$object, 'init']);
}
return $object;