RemoveNewArrayCollectionOutsideConstructorRector

Remove new ArrayCollection() assigns outside constructor

+namespace Rector\Doctrine\Tests\TypedCollections\Rector\ClassMethod\RemoveNewArrayCollectionOutsideConstructorRector\Fixture;
+
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;

 final class NoAssignOutsideConstructor
 {
     public Collection $items;

     public function anotherMethod()
     {
-        $this->items = new ArrayCollection();
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\ClassMethod\RemoveNewArrayCollectionOutsideConstructorRector;

return RectorConfig::configure()
    ->withRules([
        RemoveNewArrayCollectionOutsideConstructorRector::class,
    ]);