From 4667d35e842cfdef714617b11c3e3b7749798425 Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Tue, 19 Nov 2024 16:25:20 +0100 Subject: [PATCH] [TASK] Compat with phpstan/phpstan:^2 https://github.com/phpstan/phpstan-src/blob/2.0.x/UPGRADING.md#removed-deprecated-parametersacceptorselectorselectsingle --- composer.json | 2 +- src/ContainerDynamicReturnTypeExtension.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 0273a8e..755480b 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "require": { "php": "^7.0|^8.0", "psr/container": "^1.0|^2.0", - "phpstan/phpstan": "^1.0" + "phpstan/phpstan": "^1.0|^2.0" }, "autoload": { "psr-4": { diff --git a/src/ContainerDynamicReturnTypeExtension.php b/src/ContainerDynamicReturnTypeExtension.php index 62cb230..7ba2366 100644 --- a/src/ContainerDynamicReturnTypeExtension.php +++ b/src/ContainerDynamicReturnTypeExtension.php @@ -30,17 +30,17 @@ public function getTypeFromMethodCall(MethodReflection $reflection, MethodCall $ { $args = $methodCall->getArgs(); if (count($args) === 0) { - return ParametersAcceptorSelector::selectSingle($reflection->getVariants())->getReturnType(); + return ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $reflection->getVariants())->getReturnType(); } $arg = $args[0]->value; // Care only for ::class parameters, we can not guess types for random strings. if (!$arg instanceof ClassConstFetch) { - return ParametersAcceptorSelector::selectSingle($reflection->getVariants())->getReturnType(); + return ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $reflection->getVariants())->getReturnType(); } $argType = $scope->getType($args[0]->value); if (!$argType instanceof ConstantStringType) { - return ParametersAcceptorSelector::selectSingle($reflection->getVariants())->getReturnType(); + return ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $reflection->getVariants())->getReturnType(); } return new ObjectType($argType->getValue());