Skip to content

Incorrect behavior of AnnotationToAttributeRector #6867

@astronom

Description

@astronom

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ec5c41a-339d-6a30-8f55-ab895f50da1e

<?php

namespace Test;

use Test\TestOther as TestOtherAlias;
use Test as TestFoo;

final class Test
{
    /**
    * @TestFoo\TestSmth
    */
    private string $foo;
    
    /**
    * @TestFoo\TestOther
    */
    private string $bar;
    
    /**
    * @TestOtherAlias
    */
    private string $baz;

}

#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_PROPERTY)]
final class TestSmth {
}

#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_PROPERTY)]
final class TestOther {
}

Responsible rules

  • AnnotationToAttributeRector

Expected Behavior

If class with attribute import as alias it should be also changed

    #[TestOtherAlias]
    private string $baz;

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