I used to get highlights for any unused constants or class constants in PhpStorm.
Now I can't get it work again. Maybe it was a plugin, I'm not sure.
What I've tried:
Declaration / Highlights of unused constants used to show automatically without running any inspection or commands.
It's possible in PHPStorm 7/8. Go to Code > Inspect Code and use a custom inspection profile. In the Inspections window, click on Add and unselect everything except PHP > Unused. That's only the unused private method I mention.
The description of "Unused declaration is: "This inspection reports classes, methods or fields in the specified inspection scope that are not used or not reachable from entry points." The classes, field and methods that IDEA are complaining about are all used/started etc.
Just use Analyze | Inspect Code with appropriate inspection enabled (Unused declaration under Declaration redundancy group). @CrazyCoder This shows unused fields and methods too, any way to show only unused classes? My 2 cents: on IntelliJ 2016.3. 4 the option is under Analyze > Run Inspection By Name.
Not the answer you wanted but this is not possible as of yet.1
I scoured through the plugin repository and the inspection options and couldn't find anything for this specific request.
The only way that this can be achieved currently is by giving your constant a private
modifier as can be seen in the image below:
and this method is not exactly ideal as it is picking up the private
rather than the const
(not to mention, you might want to globalise the const
in question).
The second option would be to create a custom inspection setting plugin and define it and again, this is not ideal.
1I have created a feature request and with the publicity of this bounty it may be possible to get this implemented, you can find the feature request here and you can vote on it too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With