Skip to content

[CodeQuality] Cheap instanceof guard before getType() in BooleanNotIdenticalToNotIdenticalRector - #8539

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-booleannot-cheaper-guard-order
Oct 8, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-booleannot-cheaper-guard-order

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

In processIdentical(), the rule computed getType() on both sides of every === node before checking the only structural precondition it needs - $identical->left instanceof BooleanNot. So for every identical comparison in a codebase whose left side is not a BooleanNot (the vast majority), it paid two full type inferences and then returned null.

Moving the cheap instanceof guard to the top makes getType() run only on the !$a === $b shape the rule can actually rewrite. Behavior is unchanged - when left is not a BooleanNot the old code also returned null, and the two type checks are independent conjuncts, so order does not affect the result.

@TomasVotruba
TomasVotruba merged commit 5e44d81 into main Oct 8, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the fix-booleannot-cheaper-guard-order branch October 8, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant