TomasVotruba / class-leak

Find leaking classes that you never use... and get rid of them.
https://tomasvotruba.com/blog/how-to-avoid-maintaining-classes-you-dont-use
MIT License
75 stars 6 forks source link

Search for used names in PHPDoc comments #38

Closed ruudk closed 5 months ago

ruudk commented 6 months ago

This depends on https://github.com/TomasVotruba/class-leak/pull/36

Fixes #35

Only the last 2 commits in this PR are new.

Rename attributes to usedAttributes

This better explains that it's about used attributes.

Search for used names in comments

By using PHPStan's PHPDoc parser, we can scan referenced types inside PHPDocs.

Next to testing all the components separately, we introduce a functional CheckCommandTest that runs the check command. Doing it this way, we make sure that everything works together.

This also allows us to add more complex test cases too.

ruudk commented 6 months ago

@TomasVotruba @samsonasik This one is ready for review, what do you think 😊 ?

ruudk commented 5 months ago

@TomasVotruba You're probably busy, but are there any things you want me to change to move this PR forward?

ruudk commented 5 months ago

@TomasVotruba Now that https://github.com/TomasVotruba/class-leak/pull/39 is merged instead of https://github.com/TomasVotruba/class-leak/pull/36, this PR is out of sync. But before I fix it up again, I'd like to hear your thoughts if you want to merge this at all 😊

TomasVotruba commented 5 months ago

Same here, I got lost in the amount of changes for the feature. Could you submit smaller PRs with very narrow focus on the feature you want to deliver? That way I can read & merge :+1: Otherwise there is a risk I'll skip it and it will stale.

On the docblock topic, I think I'd prefer to keep this package simple and require at least 1 native PHP usage. The docblock themselves are not reliable, as string-only. Project can mark 100 classes used in docblock, but none of them ever used in the code.

That's why I want to stick with native PHP only and not add docblock. Thanks for understanding :+1: