Find unused public and protected methods in PHPStorm

phpstorm

Solution

It was requested previously, and thanfully is possible since PhpStorm 2019.1 EAP #6 (see here for details).

You can create a new inspection profile with only this inspection, and use Code > Inspect code... and choose this new profile to find all dead code in your app. Note that this inspection allows you to explicitly set if you want to report fields, methods etc., with what visibility level, and to even set entry points!

Problem

PHPStorm has a handy unused private method inspection, which detects methods that are without doubt not used. I would sometimes be interested to scan my project for unused public/protected methods as well. I'm aware that this is not an exact science, and that would report methods that might be used outside this project (in the case of a library, for example), but subject to a manual review, that would probably be very useful. Is this currently possible with PHPStorm?

Original source