Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 19, 2025

In the profiles of #4628 (comment) we can see getDynamicFunctionReturnType as one of the most expensive calls:

grafik

in the happy path in which FuncCall has a Name before this PR we tend to normalize the argument list twice.

this PR remove duplicate arg normalization per FuncCall. I did not send it against fnsr-storage-branch, as I think it will not conflict with the PRs changes and makes sense on its own

if ($normalizedNode !== null && $functionName !== null && $this->reflectionProvider->hasFunction($functionName, $this)) {
$functionReflection = $this->reflectionProvider->getFunction($functionName, $this);
$resolvedType = $this->getDynamicFunctionReturnType($parametersAcceptor, $node, $functionReflection);
$resolvedType = $this->getDynamicFunctionReturnType($normalizedNode, $functionReflection);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this path we invoked getDynamicFunctionReturnType without beeing normalized beforehand.

$resolvedType = $this->getDynamicFunctionReturnType($parametersAcceptor, $normalizedNode, $functionReflection);
$resolvedType = $this->getDynamicFunctionReturnType($normalizedNode, $functionReflection);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this path $node was already normalized in line 2449 and before this PR will get normalized again within getDynamicFunctionReturnType

@ondrejmirtes ondrejmirtes merged commit a09ac35 into phpstan:2.1.x Dec 19, 2025
626 of 634 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the less-work branch December 19, 2025 09:59
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