Skip to content

Conversation

claytonrcarter
Copy link

Hi 👋

It's common to have unused method params, especially in cases where you're extending and overriding a method from a parent class. Instead of sprinkling // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter thoughout my code, I'd prefer to just rename those variables to $_variable. This is similar to how eslint and Rust's clippy handle unused params, and I've found those to be convenient and still helpful.

My only TODO is maybe putting this behind a config flag, but I didn't want to get into that until I heard if this change is desired at all. This is my first contribution here, and no AI was used in this.

This sort of addresses #1074, and it may even close it.

@kukulich
Copy link
Contributor

I'm ok to merge such feature but I would prefer to make it configurable via new option. The option should probably contain regexp.

@claytonrcarter claytonrcarter marked this pull request as draft September 2, 2025 21:18
@claytonrcarter
Copy link
Author

OK, I've updated this based on forbiddenCommentPatterns in ForbiddenCommentsSniff. Does this look OK to you? If so, I can make the test more robust. (Right now it's only testing patterns /a/ and /b/ against $a and $b, but it should probably check for something more "patterny". 😄 )

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