rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

[TypeDeclaration] Skip intersection with iterable on ReturnTypeDeclarationRector on php 8.1 feature enabled

Open samsonasik opened this issue 3 years ago • 2 comments

Given the following code:

final class SkipIntersectionIterable
{
    /** @var \Doctrine\Common\Collections\Collection<\stdClass> */
    private \Doctrine\Common\Collections\Collection $socialAccounts;

    public function __construct()
    {
        $this->socialAccounts = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /** @return \Doctrine\Common\Collections\Collection<\stdClass> */
    public function getSocialAccounts() : \Doctrine\Common\Collections\Collection
    {
        return $this->socialAccounts;
    }
}

It currently produce return type declaration with intersection consist of iterable:

-    public function getSocialAccounts() : \Doctrine\Common\Collections\Collection
+    public function getSocialAccounts() : \Doctrine\Common\Collections\Collection&iterable

which invalid.

This PR try to fix it. Fixes https://github.com/rectorphp/rector/issues/7562

samsonasik avatar Oct 28 '22 15:10 samsonasik

Fixed 🎉 /cc @stephanvierkant

samsonasik avatar Oct 28 '22 15:10 samsonasik

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

samsonasik avatar Oct 28 '22 15:10 samsonasik

All checks have passed 🎉 @TomasVotruba I think it is ready.

samsonasik avatar Oct 29 '22 03:10 samsonasik

Thank you, looks good :+1: Feel free to merge when ready

TomasVotruba avatar Oct 29 '22 10:10 TomasVotruba