Open
Description
Is your feature request related to a problem?
When using callbacks for example for filter calls on arrays and you only use the $value, the $key parameter might be unused.
There are also multiple other use cases (like workarounds for interface implementation or deep code analysis #490 ) where this could be an issue.
This is prevalent in UnusedFunctionParameterSniff
.
Describe the solution you'd like
There could be reserved names or prefixes that are ignored by the unused variable/parameter check.
Should be flagged:
$selectedCompanies = $companyOptions->values()->filter(
fn($item, $index): bool => in_array($index + 1, $selectedIndices, true)
);
Should not be flagged:
$selectedCompanies = $companyOptions->values()->filter(
fn($_, $index): bool => in_array($index + 1, $selectedIndices, true)
);
Additional context (optional)
A similar thing has already been added for PHPMD: phpmd/phpmd#278
phpmd/phpmd#319
For consistency's sake I would suggest a similar or the same approach.
- I have read the Contribution Guidelines and this is not a support question.
- I intend to create a pull request to implement this feature.