Skip to content

About

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

Topics

Resources

Stars

156 stars

Watchers

2 watching

Forks

Repository files navigation

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


Exclude what you use

Do you want to skip classes of certain type?

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

Classes ending with Controller, Test or TestCase are skipped by default, as they are called by the router or the test runner. What if your other classes do no implement any type?

vendor/bin/class-leak check src --skip-suffix="Handler"

Do you want to skip classes using a specific attribute?

vendor/bin/class-leak check src --skip-attribute="App\\Attribute\\AsController"

Fast mode (Go port, experimental)

A Go port of the same checks is included as a proof of concept. Enable it with --blink:

vendor/bin/class-leak check src --blink

It reuses the same options and output. The bin/class-leak-go launcher builds the binary on first run, so a Go toolchain is required.


Happy coding!

About

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

Topics

Resources

Stars

156 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages