Remove new ArrayCollection wrap on collection typed property, as it is always assigned in the constructor
-use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
final class SomeClass
{
public ?Collection $items;
public function someMethod()
{
- $values = new ArrayCollection($this->items);
+ $values = $this->items;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\New_\RemoveNewArrayCollectionWrapRector;
return RectorConfig::configure()
->withRules([
RemoveNewArrayCollectionWrapRector::class,
]);