rectorphp / rector

Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
https://getrector.com
MIT License
8.72k stars 687 forks source link

Gedmo annotation are transformed and broken when applying a minimal set #3131

Closed Nuscly closed 4 years ago

Nuscly commented 4 years ago

Bug Report

Subject Details
Rector version rector/rector@sha256:c0c95f18e305a299448765e51d94027b4111b4a97476809c3e3644639933f9e1
Installed as with docker as it's a php 7.0 project processed: rector/rector:latest from this week

On this project, we are migrating Symfony version, but even with a minimal set, I can reproduce the bug, the rector [applying] Rector\Renaming\Rector\Class_\RenameClassRector is applied many time on the file, and is the only one.

rector.yml file:

parameters:
    sets:
        - 'twig112'
    php_version_features: '7.0'

Minimal PHP Code Causing Issue

I try to reproduce here https://getrector.org/demo/289ca160-fe8b-4cfd-bef4-463c5804761b#result but it fails due to missing extension.

Boggus transformation:

    ---------- begin diff ----------
--- Original
+++ New
@@ -249,7 +249,7 @@
     /**
      * @var string
      *
-     * @Gedmo\Slug(fields={"lastName", "firstName"}, prefix="papo-")
+     * @Gedmo\Slug(fields={"lastName", "firstName"})
      * @ORM\Column(type="string", length=128)
      */
     protected $gitoliteName;
@@ -315,7 +315,7 @@
     /**
      * @var User
      *
-     * @Gedmo\Blameable(on="create")
+     * @Gedmo\Blameable(create)
      * @ORM\ManyToOne(targetEntity="Akeneo\Bundle\UserBundle\Entity\User")
      * @ORM\JoinColumn(name="created_by", referencedColumnName="id", onDelete="CASCADE")
      * @Assert\Type("Akeneo\Bundle\UserBundle\Entity\User", groups={"scoring"})
@@ -325,7 +325,7 @@
     /**
      * @var User
      *
-     * @Gedmo\Blameable(on="update")
+     * @Gedmo\Blameable(update)
      * @ORM\ManyToOne(targetEntity="Akeneo\Bundle\UserBundle\Entity\User")
      * @ORM\JoinColumn(name="updated_by", referencedColumnName="id", nullable=true, onDelete="SET NULL")
      */
    ----------- end diff -----------

Expected Behaviour

All the Gedmo annotation properties should be kept, but some are removed or transformed without any reason.

TomasVotruba commented 4 years ago

These 2 cases are fixed now.

There might be more Gedmo annotation issues, since we have to cover them all 1:1 to real anotations. So feel free to report them

Nuscly commented 4 years ago

Thanks for the quick fix, I will check that.