Skip to content

Add test fixture for demonstrating behavior changing parentheses remo…#8121

Closed
j-dobr wants to merge 1 commit into
rectorphp:mainfrom
j-dobr:Incorrect-behavior-of-SimplifyConditionsRector
Closed

Add test fixture for demonstrating behavior changing parentheses remo…#8121
j-dobr wants to merge 1 commit into
rectorphp:mainfrom
j-dobr:Incorrect-behavior-of-SimplifyConditionsRector

Conversation

@j-dobr

@j-dobr j-dobr commented Jun 30, 2026

Copy link
Copy Markdown

This condition evaluates as false:

if (! (1 < (1 ? 2 : 1))) {
}

But it is simplified into this, which, due to removal of parentheses around inner condition, evaluates as true:

if (1 >= 1 ? 2 : 1) {
}

Added failing fixture (might not be minimal reproducer, but it illustrates it nicely).

@j-dobr j-dobr deleted the Incorrect-behavior-of-SimplifyConditionsRector branch June 30, 2026 11:37
simonschaufi pushed a commit to simonschaufi/rector-src that referenced this pull request Jul 2, 2026
…itionsRector (rectorphp#8122)

Fixes rectorphp#8121 - inverting a binary op whose operand is a ternary dropped the parentheses, changing evaluation due to lower ternary precedence.
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