-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use normal Collection<ClassName> when property has indexBy (#359)
* Use normal array<Collection> when property has indexBy * fix phpstan * fix phpstan
- Loading branch information
1 parent
a0ab15c
commit 22bc264
Showing
9 changed files
with
174 additions
and
10 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...oCollectionPropertyGetterByToManyAnnotationRector/Fixture/OneToMany/with_index_by.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\OneToMany; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training; | ||
|
||
#[ORM\Entity()] | ||
class Trainer | ||
{ | ||
/** | ||
* @var Collection|Training[] | ||
*/ | ||
#[ORM\OneToMany(targetEntity: Training::class, indexBy: "id", mappedBy: "trainer")] | ||
private $trainings = []; | ||
|
||
public function getTrainings() | ||
{ | ||
return $this->trainings; | ||
} | ||
|
||
public function setTrainings($trainings) | ||
{ | ||
$this->trainings = $trainings; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\OneToMany; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training; | ||
|
||
#[ORM\Entity()] | ||
class Trainer | ||
{ | ||
/** | ||
* @var Collection|Training[] | ||
*/ | ||
#[ORM\OneToMany(targetEntity: Training::class, indexBy: "id", mappedBy: "trainer")] | ||
private $trainings = []; | ||
|
||
/** | ||
* @return \Doctrine\Common\Collections\Collection<\Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training> | ||
*/ | ||
public function getTrainings() | ||
{ | ||
return $this->trainings; | ||
} | ||
|
||
public function setTrainings($trainings) | ||
{ | ||
$this->trainings = $trainings; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ty/ImproveDoctrineCollectionDocTypeInEntityRector/Fixture/OneToMany/with_index_by.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture\OneToMany; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training; | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class WithIndexBy | ||
{ | ||
/** | ||
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer", "indexBy"="id") | ||
* @var Collection<int, string>|Training[] | ||
*/ | ||
private $trainings = []; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture\OneToMany; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training; | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class WithIndexBy | ||
{ | ||
/** | ||
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer", "indexBy"="id") | ||
* @var \Doctrine\Common\Collections\Collection<\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training> | ||
*/ | ||
private $trainings = []; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters