From d7ab423a0a4c4b788b03abc1c8b6e9cbb1ae2c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 3 Aug 2023 14:02:06 +0800 Subject: [PATCH] qqq --- Container.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Container.php b/Container.php index 36e295e..898933c 100644 --- a/Container.php +++ b/Container.php @@ -108,7 +108,17 @@ class Container implements ContainerInterface if (isset($this->_singletons[$id])) { 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 { return match ($parameter->getType()) { - 'string' => '', - 'int', 'float' => 0, + 'string' => '', + 'int', 'float' => 0, '', null, 'object', 'mixed' => NULL, - 'bool' => false, - 'default' => null + 'bool' => false, + 'default' => null }; }