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

[Php71] Skip with If always array on CountOnNullRector #1229

Merged
merged 6 commits into from Nov 14, 2021

Conversation

samsonasik
Copy link
Member

Given the following code:

final class SkipWithIfAlwaysArray
{
    public function run($a, $b)
    {
        $data = [];
        if (! $a) {
            $data[] = $b;
        }

        $data[] = count($data) !== 0 ? 'a' : 'b';
    }
}

Currently produce:

+        $data[] = (is_array($data) || $data instanceof \Countable ? count($data) : 0) !== 0 ? 'a' : 'b';

which should be askipped as always array.

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 759b5f9 into main Nov 14, 2021
@TomasVotruba TomasVotruba deleted the skip-with-if-always-array branch November 14, 2021 08:32
@TomasVotruba
Copy link
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants