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 property fetch array assigned in method call on __construct on CountOnNullRector #1698

Merged
merged 5 commits into from
Jan 19, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Jan 19, 2022

Given the following code:

final class SkipPropertyArrayFilledByConstructViaMethodCall
{
    /** @var array */
    private $property;

    public function __construct()
    {
        $this->fill();
    }

    private function fill()
    {
        $this->property = [];
    }

    public function run(): int
    {
        return count($this->property);
    }
}

It produce:

-        return count($this->property);
+        return count((array) $this->property);

which should be skipped.

@samsonasik samsonasik changed the title [Php71] Skip property fetch array assigned in method call on CountOnNullRector [Php71] Skip property fetch array assigned in method call on __construct on CountOnNullRector Jan 19, 2022
@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 dbf1320 into main Jan 19, 2022
@TomasVotruba TomasVotruba deleted the skip-property-fetch-array-method-call branch January 19, 2022 08:48
@TomasVotruba
Copy link
Member

Neat work 👍
I was thinking about inside the method checks, but it seemed too big challange. Thanks for taking this one 👏

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