rector icon indicating copy to clipboard operation
rector copied to clipboard

Doctrine Annotation to Attributes - InverseJoinColumn is converted to JoinColumn

Open Chris53897 opened this issue 2 years ago • 2 comments

Rector version: https://github.com/rectorphp/rector/commit/80bfee9246e1b57194c2119558962a2983bd2798 Update: I run this under PHP 8.1.

DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES

The InverseJoinColumn ist not converted correct. It is converted to JoinColumn.

Before:

/**
* @ORM\ManyToMany(targetEntity="App\Entity\Liste")
* @ORM\JoinTable(name="liste_kontingente",
*    joinColumns={@ORM\JoinColumn(name="kontingent_id", referencedColumnName="id")},
*    inverseJoinColumns={@ORM\JoinColumn(name="liste_id", referencedColumnName="id")}
*   )
 */
protected Collection $listen;

After:

#[ORM\ManyToMany(targetEntity: Liste::class)]
#[ORM\JoinTable(name: 'liste_kontingente', joinColumns: [], inverseJoinColumns: [])]
#[ORM\JoinColumn(name: 'kontingent_id', referencedColumnName: 'id')]
#[ORM\JoinColumn(name: 'liste_id', referencedColumnName: 'id')]
protected Collection $listen;

Correct:

#[ORM\ManyToMany(targetEntity: Liste::class)]
#[ORM\JoinTable(name: 'liste_kontingente', joinColumns: [], inverseJoinColumns: [])]
#[ORM\JoinColumn(name: 'kontingent_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'liste_id', referencedColumnName: 'id')]
protected Collection $listen;

Chris53897 avatar Aug 05 '22 14:08 Chris53897

@acrobat this maybe similar issue with issue that you resolve on PR

  • https://github.com/rectorphp/rector-src/pull/2699

Could you verify it and possible provide a patch for it? Thank you.

samsonasik avatar Aug 05 '22 15:08 samsonasik

Thank you @Chris53897 for reporting this issue. I can see rector did the same error in my app that I'm migrating right now.

javaDeveloperKid avatar Aug 10 '22 14:08 javaDeveloperKid

The solution is on the way :grinning: :+1: See https://github.com/rectorphp/rector-src/pull/2781

TomasVotruba avatar Aug 18 '22 18:08 TomasVotruba