Skip to content

Detect dead enum cases #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Detect dead enum cases #197

wants to merge 6 commits into from

Conversation

janedbal
Copy link
Member

@janedbal janedbal commented Apr 4, 2025

No description provided.

@ruudk
Copy link
Contributor

ruudk commented Apr 4, 2025

Just my 2 cents: I'm not sure this is a good idea. I once made a PHPStan rule to detect them. And most of the time, our enums are mapped to database state. Not every case is tested. So it will produce lots of errors. I couldn't find anything worth deleting.

@janedbal
Copy link
Member Author

janedbal commented Apr 4, 2025

@ruudk Thx, I can imagine such problems, but you can always disable the analysis:

ignoreErrors:
   - identifier: shipmonk.deadEnumCase

And some codebases may benefit from this. Also, those mapped to database can be easily detected in custom usage provider (assuming Doctrine):

#[Column(type: Types::STRING, enumType: InvoiceStatus::class]
private InvoiceStatus $status;

@ruudk
Copy link
Contributor

ruudk commented Apr 4, 2025

I just realized that we should indeed create a usage detector, great 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants