/class-leak

Find leaking classes that you never use... and get rid of them.

Primary LanguagePHPMIT LicenseMIT

Class Leak

Downloads total

Find leaking classes that you never use... and get rid of them.

Install

composer require tomasvotruba/class-leak --dev

Usage

Pass directories you want to check:

vendor/bin/class-leak check bin src

Make sure to exclude /tests directories, to keep reporting classes that are used in tests, but never used in the code-base.


Many types are excluded by default, as they're collected by framework magic, e.g. console command classes. To exclude another class, e.g. your interface collector, use --skip-type:

vendor/bin/class-leak check bin src --skip-type="App\\Contract\\SomeInterface"

What if your classes do no implement any type? Use --skip-suffix instead:

vendor/bin/class-leak check bin src --skip-suffix "Controller"

If you want to skip classes that use a specific attribute or have methods that use a specific attribute, use --skip-attribute:

vendor/bin/class-leak check bin src --skip-attribute "Symfony\\Component\\HttpKernel\\Attribute\\AsController"

Happy coding!