I get the error from PHPStan:
Property App\Entity\Product::$productArticles type mapping mismatch: property can contain Doctrine\Common\Collections\Collection but database expects Doctrine\Common\Collections\Collection&iterable<App\Entity\ProductArticle>
My variable declaration:
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductArticle::class)] /** @var Collection<int, ProductArticle> */ private Collection $productArticles;
How to use: annotation to declare ORM variables and PHPDoc annotation to declare Collection type at the same time?
PHPDoc needs to be above the properties.
This is a bug in the parser library used by PHPStan (
nikic/php-parser
). So that has to be it now.