Skip to content

Commit

Permalink
Convert annotations to attributes with known class references (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Feb 14, 2024
1 parent 0858ab3 commit ad55a28
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions config/sets/attributes/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
// class
new AnnotationToAttribute('Doctrine\ORM\Mapping\Entity'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Entity', null, ['repositoryClass']),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Column'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\UniqueConstraint'),

Expand All @@ -43,24 +43,24 @@
new AnnotationToAttribute('Doctrine\ORM\Mapping\GeneratedValue'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\SequenceGenerator'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Index'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\CustomIdGenerator'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\CustomIdGenerator', null, ['class']),

// relations
new AnnotationToAttribute('Doctrine\ORM\Mapping\OneToOne'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\OneToMany'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\ManyToMany'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\OneToOne', null, ['targetEntity']),
new AnnotationToAttribute('Doctrine\ORM\Mapping\OneToMany', null, ['targetEntity']),
new AnnotationToAttribute('Doctrine\ORM\Mapping\ManyToMany', null, ['targetEntity']),
new AnnotationToAttribute('Doctrine\ORM\Mapping\JoinTable'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\ManyToOne'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\ManyToOne', null, ['targetEntity']),

new AnnotationToAttribute('Doctrine\ORM\Mapping\OrderBy'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\JoinColumn'),

// embed
new AnnotationToAttribute('Doctrine\ORM\Mapping\Embeddable'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Embedded'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Embedded', null, ['class']),

// inheritance
new AnnotationToAttribute('Doctrine\ORM\Mapping\MappedSuperclass'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\MappedSuperclass', null, ['repositoryClass']),
new AnnotationToAttribute('Doctrine\ORM\Mapping\InheritanceType'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\DiscriminatorColumn'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\DiscriminatorMap'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use Doctrine\ORM\Mapping\CustomIdGenerator;

class User
{
#[CustomIdGenerator(class: 'MyIdGenerator')]
#[CustomIdGenerator(class: \MyIdGenerator::class)]
private $id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Address

class User
{
#[Embedded(class: 'Address')]
#[Embedded(class: \Address::class)]
private $address;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Set/DoctrineORM29Set/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use Doctrine\ORM\Mapping as ORM;
* News
*/
#[ORM\Table(name: 'news')]
#[ORM\Entity(repositoryClass: 'DoctrineFixtureDemo\Repository\NewsRepository')]
#[ORM\Entity(repositoryClass: \DoctrineFixtureDemo\Repository\NewsRepository::class)]
class News
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use Doctrine\ORM\Mapping\JoinColumn;
class User
{
#[JoinColumn(name: 'group_id', referencedColumnName: 'id')]
#[ManyToOne(targetEntity: 'HelloWorld\UserGroup', inversedBy: 'users')]
#[ManyToOne(targetEntity: \HelloWorld\UserGroup::class, inversedBy: 'users')]
protected $group;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use Doctrine\ORM\Mapping\JoinColumn;
class Product
{
#[JoinColumn(name: 'shipment_id', referencedColumnName: 'id')]
#[OneToOne(targetEntity: 'Shipment')]
#[OneToOne(targetEntity: \Shipment::class)]
private $shipment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use Doctrine\ORM\Mapping\JoinTable;
class User
{
#[JoinTable(name: 'users_phonenumbers')]
#[ManyToMany(targetEntity: 'Phonenumber')]
#[ManyToMany(targetEntity: \Phonenumber::class)]
public $phonenumbers;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Set/DoctrineORM29Set/Fixture/one_to_many.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use Doctrine\ORM\Mapping\OneToMany;

class Product
{
#[OneToMany(targetEntity: 'Feature', mappedBy: 'product')]
#[OneToMany(targetEntity: \Feature::class, mappedBy: 'product')]
private $features;
}

Expand Down

0 comments on commit ad55a28

Please sign in to comment.