Skip to content

TypeCombinator: Prevent unnecessary work#4773

Merged
ondrejmirtes merged 2 commits intophpstan:2.1.xfrom
staabm:tc
Jan 17, 2026
Merged

TypeCombinator: Prevent unnecessary work#4773
ondrejmirtes merged 2 commits intophpstan:2.1.xfrom
staabm:tc

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Jan 17, 2026

micro optimization in a very hot path

if (
$a instanceof ConstantStringType
) {
$description = $b->describe(VerbosityLevel::value());
Copy link
Copy Markdown
Contributor Author

@staabm staabm Jan 17, 2026

Choose a reason for hiding this comment

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

describe $b only when $a == ''.

before we described $b no matter which constant-value $a had

@ondrejmirtes ondrejmirtes merged commit 26e57f0 into phpstan:2.1.x Jan 17, 2026
623 of 645 checks passed
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@staabm staabm deleted the tc branch January 17, 2026 08:39
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