-
-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect behavior of AnnotationToAttributeRector with doctrine @Table annotation and uniqueConstraints option #7011
Comments
I can't reproduce in unit tests in latest rector-doctrine repo, it adds the attribute: +#[ORM\Entity]
+#[ORM\Table(name: 'categories')]
+#[ORM\UniqueConstraint(name: 'name_idx', columns: ['name'])]
+class Category It possibly resolved in latest
Demo page may show different result due to missing class. Feel free to creata failing test PR to rector-doctrine if you have different use case. |
Hi @samsonasik, I think I have a different usecase as the uniqueConstraint is not used as a standalone attribute/annotation but as part of the table attribute/annotation. I've added a failing test (atleast it failed locally) for it in rectorphp/rector-doctrine#82 |
@acrobat thank you, if you feel the issue is on rector-src and can find a fix, you can create PR to rector-src as well, the Fixture should can be placed at https://github.com/rectorphp/rector-src/tree/main/rules-tests/Php80/Rector/Class_/AnnotationToAttributeRector/FixturePhp81 as well |
@samsonasik I've tried to come up with a fix! rectorphp/rector-src#1850 |
Bug Report
When converting a
@ORM\Table
annotation withuniqueConstraints
option, this option is lost after the refactor. I debugged the issue to it's origin but wasn't sure where to submit fixes to as I needed a failing test inrector/rector-doctrine
and the fix inrector/rector-src
.I was able to trace the issue back to this change: https://github.com/rectorphp/rector-src/pull/1766/files#diff-3f761daa31da7830aaefc8ad8ed701778a120a703ad4d205965ecb0f80c52ce8R32. But I'm not sure why is was specifically added for that option and if it can be removed again. If the array item is removed I get the expected result.
Minimal PHP Code Causing Issue
See https://getrector.org/demo/db6e1e00-8128-4647-b391-28e711f077e4
Responsible rules
AnnotationToAttributeRector
Expected Behavior
The text was updated successfully, but these errors were encountered: