rectorphp/rector-doctrine

Annotation to attributes rector isn't complete

b1rdex opened this issue ยท 2 comments

Hi! I found some problems using rector to transform annotations to attributes:

  1. @Index must be moved out of @Table
    image (Table attribute was deleted as it's not necessary anymore)

  2. same for unique constraints
    image (Table attribute was deleted as it's not necessary anymore)

  3. @JoinTable should be split

image

I had to do these modifications manually after the initial rector run โ€“ these were not easy to find, partly because of silent BC by Doctrine.

I found some information about these in doctrine/orm#9334 (comment) and https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/reference/attributes-reference.html

I've reported the same issue here rectorphp/rector#7163 (comment)

Hi @b1rdex ,

thanks for the report and git diffs. It really helped me to understand what needed to changed and how ๐Ÿ™‚ At start I got really confused by Doctrine docs, that suprisingly has no manual how to upgrade even basic annotations.

Instead of making the basic rule do too many things like before, we introduced a new rule NestedAnnotationToAttributeRector and move the nested annotation extract there: rectorphp/rector-src#2781

That way we have 2 clean rules with separated jobs ๐Ÿ‘

This is already deployed in the latest Rector dev-main. Any feedback from real project with Doctrine annotation is welcomed ๐Ÿ™‚