Adds @return PHPDoc type to Collection property getter by *ToMany annotation/attribute
-use App\Entity\Training;
-
/**
* @ORM\Entity
*/
final class Trainer
{
/**
* @ORM\OneToMany(targetEntity=Training::class)
*/
private $trainings;
+ /**
+ * @return \Doctrine\Common\Collections\Collection<int, \App\Entity\Training>
+ */
public function getTrainings()
{
return $this->trainings;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector;
return RectorConfig::configure()
->withRules([
AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector::class,
]);