Skip to content

[CodeQuality] Skip empty cases on SwitchTrueToIfRector#3556

Merged
samsonasik merged 3 commits intomainfrom
skip-empty-cases
Apr 2, 2023
Merged

[CodeQuality] Skip empty cases on SwitchTrueToIfRector#3556
samsonasik merged 3 commits intomainfrom
skip-empty-cases

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;

@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.

2 participants