PHPStorm 2019.2 has a new inspection reporting unused code. But this marks a bunch of Symfony-specific cases as unused while they are not (well, some of them are more about related packages and may belong to a separate plugin, but I'm still listing them here):
getSubscribedEventskernel.event_listener should mark the listener methods as used toothe list probably continues with other kind of services being tagged as hooks in other services btw.
note: I will keep updating the list if I think about more things.
Thanks for this list, just for related issues there is also one on PhpStorm itself to provide an API for this: https://youtrack.jetbrains.com/issue/WI-47938
Maxim Kolmakov commented 2 Aug 2019 13:13
@James Antrim The main point of of the unused declaration inspection is to find unused public classes/methods :) What is missing is additional support for frameworks magic which is provided by 3rd-party Symfony/Laravel plugin and our own Drupal.
Drupal is covered by WI-47049 and Symfony by this issue. We will implement the required API and provide a PR to the plugins that will solve all the listed issue that is why umbrella issue is better in this case than separately listed problems.
controller methods should be marked as used when a route is defined for them
I'd see it as a bonus if they're only be marked as used if that route is actually used anywhere and/or the method is referenced (i.e. controller('...') in a Twig template)
that would be an issue to me. Routes define public entry points to your site (at least GET routes for websites). Knowing whether these routes are used would involve scanning all external links pointing to your site too.
getX, addX, removeX.I'd see it as a bonus if they're only be marked as used if that route is actually used anywhere and/or the method is referenced (i.e.
controller('...')in a Twig template)
$route = 'home_' . $user->getUserType()';
$url = $this->generateUrl($route);
Good luck with that :smirk:
Good points indeed. 馃槉 But maybe still viable as an option which is off by default
Just to add if it wasn't already:
Most helpful comment
that would be an issue to me. Routes define public entry points to your site (at least GET routes for websites). Knowing whether these routes are used would involve scanning all external links pointing to your site too.