Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Php56][Php70] Handle infinite loop on TernaryToNullCoalescingRector+AddDefaultValueForUndefinedVariableRector #3639

Merged
merged 4 commits into from
Apr 20, 2023

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Apr 20, 2023

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @nerones

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@samsonasik
Copy link
Member Author

@TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 8425c90 into main Apr 20, 2023
@samsonasik samsonasik deleted the close-7889 branch April 20, 2023 13:46
return true;
}

if ($this->isAsCoalesceLeftOrAssignOpCoalesceVar($parentNode, $variable)) {
if ($this->issetOrUnsetOrEmptyParent($parentNode)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@samsonasik I think it could make sense to re-order the skipchecking methods so e.g. doing AST traversing only after cheaper checks have been done

Copy link
Member Author

Choose a reason for hiding this comment

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

This patch is to ensure no infinite loop by check coalesce early, which check coalesce later cause infinite loop, see https://getrector.com/demo/289e4c81-adae-4062-8a7a-2ad51c53c711

feel free to provide improvement PR 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@staabm I created PR #3643 for that.

@nerones
Copy link
Contributor

nerones commented Apr 20, 2023

Amazing job, thanks.

I really like this tool I hope that at some point I will able to contribute something.

samsonasik added a commit that referenced this pull request May 8, 2023
…AddDefaultValueForUndefinedVariableRector (#3639)

* reproduce hang

* Closes rectorphp/rector#7889

* clean up

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
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.

Rector hangs with no output
4 participants