diff --git a/composer.json b/composer.json index 0273a8e..aa0deb4 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": "^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());