Skip to content
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

RemoveUnusedAliasRector removes aliases even though they are referenced in a class constant #5687

Closed
Tracked by #10
DieterHolvoet opened this issue Feb 26, 2021 · 1 comment · Fixed by #5691
Closed
Tracked by #10
Labels

Comments

@DieterHolvoet
Copy link

Bug Report

Subject Details
Rector version 0.9.10
Installed as prefixed Rector

RemoveUnusedAliasRector removes aliases even though they are referenced in a class constant.

Minimal PHP Code Causing Issue

<?php

namespace App;

use App\Bar as BarAlias;

class Foo
{
    private $classMap = [
        BarAlias::class => 'bar',
    ];
}

Expected Behaviour

The alias should not be removed.

@samsonasik
Copy link
Member

After PR rectorphp/rector-src#784 , I think ClassConstFetch should be removed too if there is no conflict with use alias, it only make sense to have alias only if has conflict name in use statement.

I created a PR rectorphp/rector-src#785 for it.

TomasVotruba added a commit that referenced this issue Mar 4, 2024
rectorphp/rector-src@7df4894 [Performance][DeadCode] Early check has private methods before find() on dynamic call checks on RemoveUnusedPrivateMethodRector (#5687)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants