From 2877f3faa5378782b3dda1b75942f3d9ae59a83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 12:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Container.php | 4 +++- Inject/ContainerParams.php | 2 +- Inject/ServiceParams.php | 2 +- Interface/InjectParameterInterface.php | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Container.php b/Container.php index f60cb1e..112af7c 100644 --- a/Container.php +++ b/Container.php @@ -252,6 +252,8 @@ class Container implements ContainerInterface return $params; } $parametersArray = $parameters->getParameters(); + + $className = $parameters->getDeclaringClass()->getName(); foreach ($parametersArray as $parameter) { $parameterAttributes = $parameter->getAttributes(); if (count($parameterAttributes) < 1) { @@ -271,7 +273,7 @@ class Container implements ContainerInterface } else { $attribute = $parameterAttributes[0]->newInstance(); - $params[$parameter->getName()] = $attribute->dispatch(); + $params[$parameter->getName()] = $attribute->dispatch($className, $parameters->getName()); } } return $params; diff --git a/Inject/ContainerParams.php b/Inject/ContainerParams.php index 9bf557e..c654029 100644 --- a/Inject/ContainerParams.php +++ b/Inject/ContainerParams.php @@ -25,7 +25,7 @@ class ContainerParams implements InjectParameterInterface * @return mixed|null * @throws \Exception */ - public function dispatch(object $class, string $method): mixed + public function dispatch(string $class, string $method): mixed { return Container::instance()->get($this->value); } diff --git a/Inject/ServiceParams.php b/Inject/ServiceParams.php index 417fd79..1f9f847 100644 --- a/Inject/ServiceParams.php +++ b/Inject/ServiceParams.php @@ -27,7 +27,7 @@ class ServiceParams implements InjectParameterInterface * @return mixed|null * @throws Exception */ - public function dispatch(object $class, string $method): mixed + public function dispatch(string $class, string $method): mixed { $service = Container::instance()->get(LocalService::class); diff --git a/Interface/InjectParameterInterface.php b/Interface/InjectParameterInterface.php index afb5fa4..6af75c2 100644 --- a/Interface/InjectParameterInterface.php +++ b/Interface/InjectParameterInterface.php @@ -8,10 +8,10 @@ interface InjectParameterInterface /** - * @param object $class + * @param string $class * @param string $method * @return mixed */ - public function dispatch(object $class, string $method): mixed; + public function dispatch(string $class, string $method): mixed; }