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

[CodeQuality] Skip empty cases on SwitchTrueToIfRector #3556

Merged
merged 3 commits into from
Apr 2, 2023

Conversation

samsonasik
Copy link
Member

Per #3535 (comment), if empty cases not skipped, it will got error:

There was 1 error:

1) Rector\Tests\CodeQuality\Rector\Switch_\SwitchTrueToIfRector\SwitchTrueToIfRectorTest::test with data set #1
Rector\Core\Exception\ShouldNotHappenException: Array of nodes cannot be empty. Ensure "Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector->refactor()" returns non-empty array for Nodes.

A) Return null for no change:

    return null;

B) Remove the Node:

    $this->removeNode($node);
    return $node;

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
@samsonasik samsonasik requested a review from TomasVotruba as a code owner April 2, 2023 21:34
@samsonasik
Copy link
Member Author

@TomasVotruba it fixed 🎉

@samsonasik samsonasik enabled auto-merge (squash) April 2, 2023 21:37
@samsonasik samsonasik disabled auto-merge April 2, 2023 21:39
@samsonasik samsonasik enabled auto-merge (squash) April 2, 2023 21:40
@samsonasik samsonasik merged commit 3cbf710 into main Apr 2, 2023
@samsonasik samsonasik deleted the skip-empty-cases branch April 2, 2023 21:40
@TomasVotruba
Copy link
Member

Thanks 🥳

samsonasik added a commit that referenced this pull request May 8, 2023
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.

None yet

2 participants