Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 24, 2026

late-resolvable return types are already resolved within the parameter acceptor

$functionReflection = $this->reflectionProvider->getFunction($node->name, $scope);
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs($scope, $node->getArgs(), $functionReflection->getVariants(), $functionReflection->getNamedArgumentsVariants());
$returnType = TypeUtils::resolveLateResolvableTypes($parametersAcceptor->getReturnType());
$returnType = $parametersAcceptor->getReturnType();
Copy link
Contributor Author

@staabm staabm Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my initial idea which made me visit this code was, whether we can cache the TypeSpecifierContext per CallLike, in case its a native non-conditional return type of a single-variant callable.

turns out I cannot detect at this level whether the return type is conditional, because its already resolved.

any idea how I could do it instead?

update: found a way #4817

@ondrejmirtes ondrejmirtes merged commit 583d6af into phpstan:2.1.x Jan 25, 2026
628 of 639 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the rm66 branch January 25, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants