Skip to content

Commit

Permalink
[TASK] Compat with phpstan/phpstan:^2
Browse files Browse the repository at this point in the history
  • Loading branch information
lolli42 committed Nov 19, 2024
1 parent 9cc9f6e commit 4480a55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/ContainerDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 4480a55

Please # to comment.