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

Fails to recognize import useful for PHPDoc Annotation(s), PHPStorm 2016.2 #59

Closed
skvskv opened this issue Jul 14, 2016 · 13 comments
Closed
Labels

Comments

@skvskv
Copy link

skvskv commented Jul 14, 2016

The plugin falsely considers an import of a class unused provided the class is mentioned in PHPDoc Annotations and never addressed in code in any way.

It has never been this way in PHPStorm 2016.1 and appeared after update to 2016.2
screenshot

@King2500
Copy link
Contributor

Maybe this has to do with the recently added "alias" feature.

What happens if you use:

use Zend\Form\Annotation as Annotation;

@upyx
Copy link

upyx commented Jul 14, 2016

I have the same problem. "Alias" feature not resolve it. Also I cannot check and replace all imports in project. However PHPStorm don't check an import with alias but only if alias differs from the import.

@PeekAndPoke
Copy link

I have the same issue with IntelliJ IDEA 2016.2. This used to work fine in previous versions. I fix is highly appreciated !

@skvskv
Copy link
Author

skvskv commented Jul 18, 2016

Everyone is also welcome to pick on JetBrains on their youtrack:
Vote for https://youtrack.jetbrains.com/issue/WI-32557

@Haehnchen Haehnchen added the todo label Jul 18, 2016
@Haehnchen
Copy link
Owner

note for me:

  • there is a blacklist for classes named: "Annotation"; conflicts?
  • Zend\Form\Annotation is just a folder

@nsknewbie
Copy link

Same for me!

Noticed some things:

  1. use Zend\Form\Annotation; marked as unused
  2. use Zend\Form\Annotation as Annotation; still marked as unused
  3. use Zend\Form\Annotation as Test; is NOT marked as unused even if there are no uses in annotations

Seems giving an alias with different name is the only working workaround for now

@skvskv
Copy link
Author

skvskv commented Jul 29, 2016

@Haehnchen, may it be fixed at all?

@Haehnchen
Copy link
Owner

so indeed as testing says PhpStorm 2016.2 issue

@skvskv
Copy link
Author

skvskv commented Jul 29, 2016

@Haehnchen , thank you for making the matter clear.
Would you be so kind and support reopening the issue on youtrack?

@Haehnchen
Copy link
Owner

... will validate issue tomorrow

artspb added a commit to artspb/idea-php-annotation-plugin that referenced this issue Jul 31, 2016
Reference can point not only to a class but also to a namespace e.g. @annotation\Exclude()
Haehnchen added a commit that referenced this issue Jul 31, 2016
@Haehnchen Haehnchen added fixed and removed todo labels Jul 31, 2016
@Haehnchen
Copy link
Owner

Haehnchen commented Jul 31, 2016

fixed by #63 and released

@artspb
Copy link
Contributor

artspb commented Jul 31, 2016

  1. Since 2016.2 PhpStorm partially supports namespace imports. Zend\Form\Annotation is a namespace thus its import can be removed if unused. Let's take a look on the cases by @nsknewbie:

    1.1. use Zend\Form\Annotation; marked as unused because the plugin doesn't provide with the references to this element.
    1.2. use Zend\Form\Annotation as Annotation; is technically the same import as the previous one.
    1.3. use Zend\Form\Annotation as Test; is not removed because PS doesn't support namespace aliases ATM.

  2. My sentence "the plugin doesn't provide with the references to this element" is not fully correct. Actually the plugin does provide with the references. But it's not enough because the reference must also properly implement #isReferenceTo() method. It can be done in many ways, here's the one of them Naive fix of #59 #63.

@skvskv
Copy link
Author

skvskv commented Aug 1, 2016

@artspb, many thanks! Accomplishment much appreciated!

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

No branches or pull requests

7 participants