Skip to content

[Php70] Deprecate ListSwapArrayOrderRector, can turn valid code into broken code - #8477

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-deprecate-list-swap-array-order
Sep 9, 2026
Merged

[Php70] Deprecate ListSwapArrayOrderRector, can turn valid code into broken code#8477
TomasVotruba merged 2 commits into
mainfrom
tv-deprecate-list-swap-array-order

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

ListSwapArrayOrderRector wraps the right-hand side of a list() assign with array_reverse(), on the premise that list() fills its targets in reverse order. That reverse order only matters when the same array variable is assigned across items (list($a[], $a[]) = [1, 2];). The rule cannot reliably tell that apart from independent assigns, so it can wrap array_reverse() where it is not wanted and turn valid code into broken code.

Deprecating it:

  • rule now implements DeprecatedInterface, body throws
  • removed from php70 and php-version-based sets
  • removed its test fixtures

https://claude.ai/code/session_015VSEwd6ef1TqwYumj3R1jn

@TomasVotruba
TomasVotruba force-pushed the tv-deprecate-list-swap-array-order branch from 1b255f3 to 3a69c96 Compare September 9, 2026 07:51
@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 9, 2026 07:52
@TomasVotruba
TomasVotruba merged commit f5ec53a into main Sep 9, 2026
43 checks passed
@TomasVotruba
TomasVotruba deleted the tv-deprecate-list-swap-array-order branch September 9, 2026 07:53
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