[internal] Fix inline replace block removal not removed on deep block for InlineIfToExplicitIfRector + ReplaceBlockToItsStmtsRector#7764
Merged
samsonasik merged 2 commits intomainfrom Dec 21, 2025
Conversation
… for InlineIfToExplicitIfRector + ReplaceBlockToItsStmtsRector
samsonasik
commented
Dec 21, 2025
| if ($originalNodeNodeClass !== $return::class) { | ||
| // stop traversing as node type changed and visitors won't work | ||
| return $nodes; | ||
| continue 2; |
Member
Author
There was a problem hiding this comment.
@TomasVotruba this is the fix, it will continue to next nodes as node is on outer loop of collection of nodes, as different nodes not yet visited :)
Member
There was a problem hiding this comment.
I thought return would stop everything too soon.
Looks good 👍
Member
Author
|
@TomasVotruba ready 👍, let's merge as this obvious bug :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per #7717 (review)
Ref https://getrector.com/demo/325600d2-b50f-4c59-aff5-66e0a8519ebb
That cause deep
{}empty not removed byReplaceBlockToItsStmtsRectoras the$nodesabove too early removed and stopped.This PR add fixture test and will provide a patch for it :)