Skip to content
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

Add a standard way to indicate that a parameter is unused #1

Open
TysonAndre opened this issue Oct 26, 2019 · 3 comments
Open

Add a standard way to indicate that a parameter is unused #1

TysonAndre opened this issue Oct 26, 2019 · 3 comments

Comments

@TysonAndre
Copy link
Member

TysonAndre commented Oct 26, 2019

Such as @param Type $paramName description @unused-param (on a single line after $paramName)

(Phan uses @phan-unused-param. It suppresses warnings about unused params/variables starting with $unused or with a name of $_)

@TysonAndre
Copy link
Member Author

cc @ondrejmirtes @muglug @staabm - I can see this being useful to avoid the need to rename parameters to suppress warnings for individual parameters, as well as to avoid different suppression annotations for different tools

@staabm
Copy link

staabm commented Jul 14, 2020

When named parameters are a thing with php8 renaming a parameter could be a bc break, therefore using a annotation to indicate this sounds more robust.

👍

TysonAndre added a commit to phan/phan that referenced this issue Jul 16, 2020
@TysonAndre
Copy link
Member Author

Also, it seems like it would be unnecessarily duplication to need to specify the type, and some tools might treat leaving out the type (@param $arg @unused-param) as hinting something is mixed, or a code smell.

So adding a new annotation such as /** @unused-param [...]$paramName */ is another possibility, possibly in combination with the modifier on @param (not sure how variadic params should be referred to as)

  • Some tools might treat this as marking the function as unused. That's probably a bug if the hyphen isn't checked for.

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

No branches or pull requests

2 participants