Skip to content

[DeadCode][Php80] Handle crash on mix ClassPropertyAssignToConstructorPromotionRector+RemoveParentDelegatingConstructorRector - #7794

Closed
samsonasik wants to merge 4 commits into
mainfrom
crash-mix-prop
Closed

[DeadCode][Php80] Handle crash on mix ClassPropertyAssignToConstructorPromotionRector+RemoveParentDelegatingConstructorRector#7794
samsonasik wants to merge 4 commits into
mainfrom
crash-mix-prop

Conversation

@samsonasik

Copy link
Copy Markdown
Member

…rPromotionRector+RemoveParentDelegatingConstructorRector
Comment thread src/Rector/AbstractRector.php Outdated
Comment on lines +140 to +146
// this reindex is needed as when multiple rules apply
// the existing node position can already be removed/moved by different rule from "parent" node
//
// that modify/remove deep node, for example:
// - first rule: - Class_ → ClassMethod → remove index 0
// - second rule: - ClassMethod → here fetch the index 0 no longer exists
NodeAttributeReIndexer::reIndexNodeAttributes($node);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomasVotruba this is the fix, the reindex early before refactor() is needed, as the node position can already be removed by other rule that use parent node as node type to check.

I added comment above for future reference.

@samsonasik

Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @raneomik

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

@samsonasik

samsonasik commented Jan 3, 2026

Copy link
Copy Markdown
Member Author

@TomasVotruba I created alternative PR for it at:

which reindex is only on after refactor when refactored node returned, but with traverser to avoid issues when multiples rules apply, and higher node remove deep node so reindex is needed in deep.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Type error in "RemoveParentDelegatingConstructorRector::matchParentConstructorCallArgs" in a combination with a large PhpSet

1 participant