rectorphp / rector

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

Incorrect behavior of AnnotationToAttributeRector #8301

Closed ZZromanZZ closed 10 months ago

ZZromanZZ commented 11 months ago

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/d2786e96-276d-420b-892e-55cc2078cc1e

<?php

declare(strict_types = 1);

namespace App\Model\User;

/**
 * @\Doctrine\ORM\Mapping\Entity()
 * @\Doctrine\ORM\Mapping\Table("user", indexes={
 *  @\Doctrine\ORM\Mapping\Index(name="name_index", columns={"name"}),
 *  @\Doctrine\ORM\Mapping\Index(name="surname_index", columns={"surname"}),
 * })
 * @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("azureB2cUuid")
 * @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("uuid")
 * @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("email")
 */
class Entity {

    /**
     * @\Symfony\Component\Validator\Constraints\NotBlank()
     * @\Symfony\Component\Validator\Constraints\Email(mode="strict")
     * @\Doctrine\ORM\Mapping\Column(type="string", unique=true)
     * @\Symfony\Component\Serializer\Annotation\Groups({"import", "export-user", "export-claim"})
     */
    protected string $email = "";
}

Responsible rules

Expected Behavior

Annotations shouldn't be removed but converted to attributes

TomasVotruba commented 11 months ago

@samsonasik Hi Abdul, could you check this one? Seems something serious is going wrong here :thinking:

samsonasik commented 11 months ago

I will try

samsonasik commented 11 months ago

The issue seems due to FQCN @\ for class name resolving, change to use use statement seems working ok

https://getrector.com/demo/87df3f3b-438c-461d-bfd1-4d0aaa3bcf5e