Skip to content

Commit

Permalink
add fixutre for var and attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 14, 2024
1 parent 11ac7b9 commit cec46f7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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;

Expand All @@ -19,7 +18,6 @@ class NoVar

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;

Expand Down
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;

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;

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<int, Training>
*/
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings = [];

/**
* @param Collection|\Training[] $trainings
*/
public function setTrainings($trainings)
{
$this->trainings = $trainings;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(ImproveDoctrineCollectionDocTypeInEntityRector::class);
};
return RectorConfig::configure()
->withRules([ImproveDoctrineCollectionDocTypeInEntityRector::class])
->withPhpVersion(\Rector\ValueObject\PhpVersionFeature::ATTRIBUTES);

0 comments on commit cec46f7

Please sign in to comment.