Skip to content

AnnotationToAttributeRector misbehaves since v0.18.0 #8150

@lucasmirloup

Description

@lucasmirloup

Bug Report

Subject Details
Rector version v0.18.0

As of Rector v0.18.0, when using multiple set lists containing AnnotationToAttributeRector rules, only some of them gets applied.

It seems that one set list overwrites this rule's configuration instead of "appending" / "merging" it.

Rector v0.17.13 works as expected.

disableParallel doesn't fix the problem.

Minimal PHP Code Causing Issue

Example using 2 set lists : https://getrector.com/demo/f6e6bf2b-d116-4fb3-924f-4947cf77eb5e

Example using 1 set list : https://getrector.com/demo/3d8941dc-d136-4892-939f-e8c747bcc551

Expected Behaviour

All annotations handled by the enabled set lists should be converted to attributes (in this case : ORM, Gedmo, etc.).

Using the same PHP demo file on my machine, Rector v0.17.13 produces this output, which is the intended behavior :

<?php

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;

#[ORM\Table(name: 'test')]
#[ORM\Entity]
final class Test
{
    use TimestampableEntity;

    #[ORM\Id]
    #[ORM\Column(type: 'string')]
    protected string $id;

    #[Gedmo\SortablePosition]
    #[ORM\Column(type: 'integer', nullable: false)]
    protected int $position;

    public function getId(): string
    {
        return $this->id;
    }

    public function getPosition(): int
    {
        return $this->position;
    }

    public function setPosition(int $position): static
    {
        $this->position = $position;

        return $this;
    }
}

Thank you for your work on Rector, tell me if you need any additional information 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions