Add "Doctrine\Common\Collections\Collection" type declaration, based on @ORM\*toMany and @ODM\*toMany annotations/attributes
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\ManyToMany;
+use Doctrine\Common\Collections\Collection;
class SimpleColumn
{
/**
* @ORM\OneToMany(targetEntity="App\Product")
*/
- private $products;
+ private Collection $products;
#[ManyToMany(targetEntity: 'App\Car')]
- private $cars;
+ private Collection $cars;
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\Property\TypedPropertyFromToManyRelationTypeRector;
return RectorConfig::configure()
->withRules([
TypedPropertyFromToManyRelationTypeRector::class,
]);