From 8949f91117df8670b6f96ba8b12b05d48ceaf9dd Mon Sep 17 00:00:00 2001 From: Johnson Page Date: Wed, 2 Oct 2024 21:22:24 +1000 Subject: [PATCH] Fix deprecated ParametersAcceptorSelector::selectSingle (#12136) * Fix deprecated ParametersAcceptorSelector::selectSingle * Simplify extension code --------- Co-authored-by: Jordi Boggiano --- src/Composer/PHPStan/ConfigReturnTypeExtension.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Composer/PHPStan/ConfigReturnTypeExtension.php b/src/Composer/PHPStan/ConfigReturnTypeExtension.php index 756ad24b5..88cd635c5 100644 --- a/src/Composer/PHPStan/ConfigReturnTypeExtension.php +++ b/src/Composer/PHPStan/ConfigReturnTypeExtension.php @@ -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; } /**