Skip to content

[Php71] Convert partial list() destruct in ListToArrayDestructRector - #9028

Merged
TomasVotruba merged 2 commits into
mainfrom
list-to-array-destruct-partial
Nov 23, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
list-to-array-destruct-partial

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

list(, $x) = ... was skipped, though [, $x] = ... is valid since PHP 7.1.

The skip came from #7909 (fixing rectorphp/rector#9668): the rule built an Array_ from the list items, and a skipped slot (null item) crashed PHPStan scope refresh - Array_ items must not be null.

Now the node stays a List_ and only switches to the short [] kind, so null items are fine and partial destructs convert:

-list(, $instance_id) = explode(':', $rate->id);
+[, $instance_id] = explode(':', $rate->id);

skip_partial_destruct.php.inc becomes partial_destruct.php.inc (the #9668 reduction), plus a foreach + middle-hole fixture. Both crash with the old Array_ conversion, so the crash stays covered.

@TomasVotruba
TomasVotruba merged commit 9a7d321 into main Nov 23, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the list-to-array-destruct-partial 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