Skip to content

[CodingStyle] Deprecate BinaryOpStandaloneAssignsToDirectRector - #8269

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-binary-op-standalone-assigns
Aug 2, 2026
Merged

[CodingStyle] Deprecate BinaryOpStandaloneAssignsToDirectRector#8269
TomasVotruba merged 1 commit into
mainfrom
deprecate-binary-op-standalone-assigns

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecates BinaryOpStandaloneAssignsToDirectRector.

The rule only fires on a very narrow shape - a method/function/closure with exactly 3 statements: 2 standalone variable assigns followed by a return with a binary op comparing those 2 variables. Outside that shape it does nothing, and inlining named variables into the comparison often makes the code less readable, not more. The purpose is unclear.

 function run()
 {
-    $value = 100;
-    $anotherValue = 200;
-
-    return $value <=> $anotherValue;
+    return 100 <=> 200;
 }

Removed from the CodingStyleLevel set, tests dropped, and the now-unused VariableAndExprAssign value object removed.

@TomasVotruba
TomasVotruba merged commit b975396 into main Aug 2, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-binary-op-standalone-assigns branch August 2, 2026 22:11
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