1
0
Fork 0

Fix deprecated ParametersAcceptorSelector::selectSingle (#12136)

* Fix deprecated ParametersAcceptorSelector::selectSingle

* Simplify extension code

---------

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
pull/12143/head
Johnson Page 2024-10-02 21:22:24 +10:00 committed by GitHub
parent 469a156b59
commit 8949f91117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -61,14 +61,12 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
return strtolower($methodReflection->getName()) === 'get';
}
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type
{
$args = $methodCall->getArgs();
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
if (count($args) < 1) {
return $defaultReturn;
return null;
}
$keyType = $scope->getType($args[0]->value);
@ -82,7 +80,7 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
$types = [];
foreach($strings as $string) {
if (!isset($this->properties[$string->getValue()])) {
return $defaultReturn;
return null;
}
$types[] = $this->properties[$string->getValue()];
}
@ -90,7 +88,7 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
return TypeCombinator::union(...$types);
}
return $defaultReturn;
return null;
}
/**