rector-src
rector-src copied to clipboard
[TypeDeclaration] Skip intersection with iterable on ReturnTypeDeclarationRector on php 8.1 feature enabled
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
Fixed 🎉 /cc @stephanvierkant
All checks have passed 🎉 @TomasVotruba it is ready for review.
All checks have passed 🎉 @TomasVotruba I think it is ready.
Thank you, looks good :+1: Feel free to merge when ready