inpsyde / php-coding-standards

Style guide for writing consistent PHP for WordPress projects.
MIT License
98 stars 23 forks source link

[Feature Request]: Add a sniff for unused services #63

Closed strangerkir closed 1 year ago

strangerkir commented 1 year ago

Is your feature request related to a problem?

A projects using Inpsyde Modularity would benefit from a sniffs detecting declared but never used services. Having with time more and more service definitions, we need an automated way of removing them.

Describe the desired solution

Add a sniff, checking for unused services.

Describe the alternatives that you have considered

Extending original sniffs detecting dead code? Would be great to help PHP_CodeSniffer to understand the container and services, then unused services probably would be detected by a regular dead code sniffer.

Additional context

No response

Code of Conduct

gmazzap commented 1 year ago

I'm not sure this is possible at all.

PHPCS does not have cross-files knowledge, and so if a service is declared in a module, but then consumed in another module it could be impossible to detect that.

strangerkir commented 1 year ago

Ok, I see. I'm closing the issue. Thanks for your answer!