Skip to content

Conversation

@samsonasik
Copy link
Member

Given the following code:

final class SkipUnionMixed
{
    private $x;

    public function __construct($x)
    {
        if (rand(0,1)) {
            $this->x = $x;
        } else {
            $this->x = null;
        }
    }
}

It currently produce:

+    /**
+     * @var mixed|null
+     */
     private $x;

which should be skipped instead.

Fixes rectorphp/rector#7640

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

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

@samsonasik
Copy link
Member Author

I Moved logic to new service: NewPhpDocFromPHPStanTypeGuard so it can be re-use and added more check if needed 0652761

@samsonasik samsonasik merged commit 91ebee8 into main Dec 6, 2022
@samsonasik samsonasik deleted the skip-union-mixed-type-assign branch December 6, 2022 10:24
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.

Incorrect behavior of TypedPropertyFromAssignsRector

3 participants