Skip to content

[CodeQuality] Skip self-assign result in SimplifyBoolIdenticalTrueRector - #9029

Merged
TomasVotruba merged 1 commit into
mainfrom
simplify-bool-identical-skip-self-assign
Nov 23, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
simplify-bool-identical-skip-self-assign

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

When the compared bool is the assigned variable itself, the rule produced a useless self-assign:

 $match = in_array($value, $items, true);
-$match = false !== $match;
+$match = $match;

Now this case is skipped. AssignedToNodeVisitor marks the assigned variable when it appears in its own ===/!== comparison, and the rule skips when the simplified result would be that very variable.

Negation still applies - $match = $match !== true becomes $match = !$match.

@TomasVotruba
TomasVotruba merged commit 02f15c4 into main Nov 23, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the simplify-bool-identical-skip-self-assign branch November 23, 2026 21:22
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