Fix deprecated ParametersAcceptorSelector::selectSingle (#12136)
* Fix deprecated ParametersAcceptorSelector::selectSingle * Simplify extension code --------- Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>pull/12143/head
parent
469a156b59
commit
8949f91117
|
@ -61,14 +61,12 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
|
||||||
return strtolower($methodReflection->getName()) === 'get';
|
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();
|
$args = $methodCall->getArgs();
|
||||||
|
|
||||||
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
|
|
||||||
|
|
||||||
if (count($args) < 1) {
|
if (count($args) < 1) {
|
||||||
return $defaultReturn;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$keyType = $scope->getType($args[0]->value);
|
$keyType = $scope->getType($args[0]->value);
|
||||||
|
@ -82,7 +80,7 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
|
||||||
$types = [];
|
$types = [];
|
||||||
foreach($strings as $string) {
|
foreach($strings as $string) {
|
||||||
if (!isset($this->properties[$string->getValue()])) {
|
if (!isset($this->properties[$string->getValue()])) {
|
||||||
return $defaultReturn;
|
return null;
|
||||||
}
|
}
|
||||||
$types[] = $this->properties[$string->getValue()];
|
$types[] = $this->properties[$string->getValue()];
|
||||||
}
|
}
|
||||||
|
@ -90,7 +88,7 @@ final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtensio
|
||||||
return TypeCombinator::union(...$types);
|
return TypeCombinator::union(...$types);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $defaultReturn;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue