phan/ProposedAnnotations

Add a standard way to indicate that a parameter is unused

Opened this issue · 3 comments

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 $_)

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

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.

👍

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.