Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[TASK] Compat with phpstan/phpstan:^2 #7

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "^1.0|^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