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

Imported classes are marked as unused when used for constant #51

Closed
stefnoten opened this issue Mar 9, 2016 · 5 comments
Closed

Imported classes are marked as unused when used for constant #51

stefnoten opened this issue Mar 9, 2016 · 5 comments

Comments

@stefnoten
Copy link

When importing classes for using its constants in an annotation, the imports are incorrectly marked as unused. Example:

namespace A;

use JMS\DiExtraBundle\Annotation as DI;
use Some\Namespace\To\MyEvents; // incorrectly marked as unused

class SomeClass {
    /** @DI\Observe(MyEvents::SOME_EVENT) */
    public function doSomething() {
    }
}

I'm using the latest version of the plugin (2.6.2). This makes it impossible to let the IDE automically optimize imports (e.g. via the shortcut or on commit). When not using this feature, it is still error-prone because mistakenly removing such an import will break the code.

@thebigb
Copy link

thebigb commented Mar 22, 2016

Dupe of #18, #22 and #26?

Those issues have been silent for a while though.

@thebigb
Copy link

thebigb commented Apr 8, 2016

@Haehnchen, I would be willing to take a look at this, but could you provide a few pointers on where to look?

Additionally do you have any tips for debugging an extension like this? I tried debugging this plugin some time ago to figure out how it works, but most breakpoints that I would set would not go off.

@acelayawonnova
Copy link

acelayawonnova commented Apr 16, 2016

@thebigb It is easy to reproduce. The doctrine/annotations package allows class constants to be passed to annotations, as in @stefnoten example, @DI\Observe(MyEvents::SOME_EVENT), the MyEvents::SOME_EVENT constant is a valid param.
However, in order to get it working, the use statement with the FQCN needs to be present, use Some\Namespace\To\MyEvents, but PhpStorm marks it as unused, making it easy to be accidentally removed, for example by automatically optimizing the use statements.

I hope that helps you :-)

@danez
Copy link

danez commented Jul 8, 2016

Can there anything be done about it? are there workarounds till this is fixed?

@Haehnchen
Copy link
Owner

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@danez @Haehnchen @thebigb @stefnoten @acelayawonnova and others