-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix attribute support in ImproveDoctrineCollectionDocTypeInEntityRect…
…or (#339) * add fixutre for var and attribute * Fix attribute support in ImproveDoctrineCollectionDocTypeInEntityRector * move attribute to own directory * extract SetterCollectionResolver * misc * add full generic collection type * improve sample to note setter as well * extract DoctrineClass enum
- Loading branch information
1 parent
11ac7b9
commit 657d715
Showing
14 changed files
with
265 additions
and
67 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
...any/skip_collection_generic_class.php.inc → ...ute/skip_collection_generic_class.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
2 changes: 1 addition & 1 deletion
2
...ny/skip_collection_generic_object.php.inc → ...te/skip_collection_generic_object.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
52 changes: 52 additions & 0 deletions
52
...rineCollectionDocTypeInEntityRector/Fixture/OneToMany/Attribute/var_and_attribute.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,52 @@ | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture\OneToMany\Attribute; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training; | ||
|
||
#[ORM\Entity] | ||
class VarAndAttribute | ||
{ | ||
/** | ||
* @var Collection|Training[] | ||
*/ | ||
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")] | ||
private $trainings = []; | ||
|
||
public function setTrainings($trainings) | ||
{ | ||
$this->trainings = $trainings; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture\OneToMany\Attribute; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training; | ||
|
||
#[ORM\Entity] | ||
class VarAndAttribute | ||
{ | ||
/** | ||
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training> | ||
*/ | ||
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")] | ||
private $trainings = []; | ||
|
||
/** | ||
* @param \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training> $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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Doctrine\CodeQuality\Enum; | ||
|
||
final readonly class DoctrineClass | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public const COLLECTION = 'Doctrine\Common\Collections\Collection'; | ||
} |
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
Oops, something went wrong.