This commit is contained in:
2023-04-16 12:49:55 +08:00
parent e9f3499f2f
commit 2877f3faa5
4 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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;
}