support container call with unnamed parameters (#103)

This commit is contained in:
sunxyw 2022-04-29 12:22:34 +08:00 committed by GitHub
parent 62b703f2e4
commit e7a8a32b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,13 @@ class BoundMethod
{
$dependencies = [];
foreach (ReflectionUtil::getCallReflector($callback)->getParameters() as $parameter) {
foreach (ReflectionUtil::getCallReflector($callback)->getParameters() as $i => $parameter) {
if (isset($parameters[$i]) && $parameter->hasType() && ($type = $parameter->getType())) {
if ($type instanceof \ReflectionNamedType && gettype($parameters[$i]) === $type->getName()) {
$dependencies[] = $parameters[$i];
continue;
}
}
static::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies);
}