Skip to content

Split MutatingScope->resolveType() into smaller methods#4759

Merged
ondrejmirtes merged 7 commits intophpstan:2.1.xfrom
staabm:refactor-scope
Jan 15, 2026
Merged

Split MutatingScope->resolveType() into smaller methods#4759
ondrejmirtes merged 7 commits intophpstan:2.1.xfrom
staabm:refactor-scope

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Jan 15, 2026

to get better blackfire profiles, I have splitted the biggest portions of resolveType() method into separate methods.

no functional changes

before this PR profiles showed we are spending most of the time in resolveType() but not where exactly:
grafik


my thesis is, that time spent on resolving types highly depends on the specific expression. to ease finding meaningfull bottlenecks code is separated into more named and independent building blocks (methods), which show up separately in profiles (after PR):

grafik

(see less tiny "down arrows" below the resolveType() box, which means we see better how time distributes from there.

Comment on lines +1656 to +1657
$callType = $this->getStaticCallType($node);
if ($callType !== null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we could prevent this null-check pattern, but for now I translated the code 1:1.
it did not always return in this cases before but let it fall thru to the below return new Mixed at the very end of the method

@ondrejmirtes ondrejmirtes merged commit 5a83f40 into phpstan:2.1.x Jan 15, 2026
624 of 644 checks passed
@ondrejmirtes
Copy link
Copy Markdown
Member

Perfect, thank you!

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