-
-
Notifications
You must be signed in to change notification settings - Fork 738
CompleteReturnDocblockFromToManyRector changes Collection key type #9682
Copy link
Copy link
Closed
rectorphp/rector-doctrine
#480Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.3.8 |
The CompleteReturnDocblockFromToManyRector replaces my already correct return type, specifically, it changes the key type of the Collection.
Sometimes a Collection can be indexed by some value, which could be a string.
Minimal PHP Code Causing Issue
https://getrector.com/demo/09c4e216-f609-46dc-bf39-4c95de2ce627
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
final class Trainer
{
/**
* @ORM\OneToMany(targetEntity=Training::class, indexBy=someField)
* @var \Doctrine\Common\Collections\Collection<string, Training>
*/
private $trainings;
/**
* @return \Doctrine\Common\Collections\Collection<string, Training>
*/
public function getTrainings()
{
return $this->trainings;
}
}<?php
use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\Class_\CompleteReturnDocblockFromToManyRector;
return RectorConfig::configure()
->withRules([
CompleteReturnDocblockFromToManyRector::class,
]);Expected Behaviour
Should not change the Collection key type from string to int.
In that particular case in the example above, should do nothing.
Reactions are currently unavailable