question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mark code as used

See original GitHub issue

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):

  • controller methods should be marked as used when a route is defined for them
  • commands should be marked as used when they are registered as commands in the container (as they are registered in the CLI)
  • event listeners should be marked as used:
    • for event subscribers, the listener methods should be marked as used based on getSubscribedEvents
    • services tagged as kernel.event_listener should mark the listener methods as used too
  • twig extension methods should be marked as used when they are references by registered functions/filters/tests (even better would be to check for usages of the function/filter/test in templates instead, but that may be too much)
  • doctrine repositories should be marked as used when they are referenced as repository in the mapping of an entity
  • constraint validators should be marked as used by their associated constraint
  • validation constraint should be marked as used when they are used in some mapping file (XML or YAML) or as annotation (this case should be handled in a generic way by the annotations plugin instead).
  • voters should be marked as used when they are registered as voters in the container

the 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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:29
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
stofcommented, Sep 4, 2019

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.

2reactions
Haehnchencommented, Sep 3, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can you mark code as "not for future use" - Stack Overflow
I thought I explained the use case above, but I'll give it another try. We have a set of core libraries which are...
Read more >
The Mark Text element - HTML: HyperText Markup Language
The <mark> HTML element represents text which is marked or highlighted for reference or notation purposes due to the marked passage's ...
Read more >
What does the ? question mark mean in JavaScript code?
The question mark ? is an alternative to an if statement best used in the case where one of two values will be...
Read more >
HTML mark Tag - W3Schools
Definition and Usage. The <mark> tag defines text that should be marked or highlighted.
Read more >
Common HTML entities used for typography - W3C Wiki
This part of the Web Standards Curriculum looks at the different codes that can be used ... The pilcrow, used to mark the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found