Skip to content

[Php85] Deprecate NestedFuncCallsToPipeOperatorRector and SequentialAssignmentsToPipeOperatorRector - #8286

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-pipe-operator-rules
Aug 4, 2026
Merged

[Php85] Deprecate NestedFuncCallsToPipeOperatorRector and SequentialAssignmentsToPipeOperatorRector#8286
TomasVotruba merged 1 commit into
mainfrom
deprecate-pipe-operator-rules

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 4, 2026

Copy link
Copy Markdown
Member

Deprecates both pipe-operator rules.

Both rules take working code and rewrite it into a |> chain. Whether that is an improvement depends entirely on the surrounding code, so it cannot be decided mechanically:

  • Extremely long chains — nothing bounds the chain length, so a deeply nested expression turns into a wall of pipes that is harder to read than what it replaced.
  • Opinionated boundary — the point where "readable pipe" becomes "too much" is a personal preference. NestedFuncCallsToPipeOperatorRector even exposes it as a minimum_depth option, which is the tell that there is no correct default.
  • The convert-all-calls flow is broken, waits for PHP 8.6 partial function https://amitmerchant.com/partial-function-application-php-86/
  • Lost variablesSequentialAssignmentsToPipeOperatorRector deletes the intermediate variables. Those names document what each step produces, and they may be re-used later.

If needed, implement as custom rule with your specific boundaries and needs.

NestedFuncCallsToPipeOperatorRector

-$result = trim(strtolower(htmlspecialchars($input)));
+$result = $input
+    |> htmlspecialchars(...)
+    |> strtolower(...)
+    |> trim(...);

Neither rule was registered in any set, so nothing is removed from `php85.php` or the levels. Rules now implement `DeprecatedInterface`, `refactor()` throws, and their tests are dropped — same shape as #8283.

…ssignmentsToPipeOperatorRector

Both rules turn working code into |> pipe chains, but where a pipe helps
depends on the code around it:

* they can build extremely long chains that break readability
* the cut-off point is an opinionated boundary, not a mechanical one
* SequentialAssignmentsToPipeOperatorRector removes intermediate variables
  that carry naming and may be re-used later
@TomasVotruba
TomasVotruba merged commit a693af0 into main Aug 4, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-pipe-operator-rules branch August 4, 2026 10:12
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