Skip to content

Printer: support lists with gaps in keys - #336

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:printer-reindex-lists
Oct 28, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:printer-reindex-lists

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

After unset($node->types[1]) or unset($phpDocNode->children[1]), printFormatPreserving() gave "Undefined array key" warnings. The differ reads the lists by position.

The printer now calls array_values() on both lists before the diff. Rector does this itself now, and can remove that code after this fix.

After unset() on a list, printFormatPreserving() gave "Undefined array key"
warnings, because the differ reads the lists by position.

Amp-Thread-ID: https://ampcode.com/threads/T-01a17930-0285-73c5-a957-4325c77aa1b2
@ondrejmirtes
ondrejmirtes merged commit 88fdee7 into phpstan:2.3.x Oct 28, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant