This commit is contained in:
2023-08-03 14:02:06 +08:00
parent e1f76a476e
commit d7ab423a0a
+15 -5
View File
@@ -108,7 +108,17 @@ class Container implements ContainerInterface
if (isset($this->_singletons[$id])) { if (isset($this->_singletons[$id])) {
return; return;
} }
$this->make($id); $object = $this->make($id);
$methods = $this->getReflectionClass($id);
foreach ($methods->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
if ($method->isStatic()) {
continue;
}
$attributes = $method->getAttributes();
foreach ($attributes as $attribute) {
$attribute->newInstance()->dispatch($object, $method->getName());
}
}
} }
@@ -377,11 +387,11 @@ class Container implements ContainerInterface
private function getTypeValue(ReflectionParameter $parameter): string|int|bool|null private function getTypeValue(ReflectionParameter $parameter): string|int|bool|null
{ {
return match ($parameter->getType()) { return match ($parameter->getType()) {
'string' => '', 'string' => '',
'int', 'float' => 0, 'int', 'float' => 0,
'', null, 'object', 'mixed' => NULL, '', null, 'object', 'mixed' => NULL,
'bool' => false, 'bool' => false,
'default' => null 'default' => null
}; };
} }