Skip to content

Ignore unused function params prefixed with _ - #6743

Merged
staabm merged 1 commit into
phpstan:2.3.xfrom
bpfoley:2.3.x
Oct 18, 2026
Merged

staabm merged 1 commit into
phpstan:2.3.xfrom
bpfoley:2.3.x

Conversation

@bpfoley

@bpfoley bpfoley commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Like variable assignment in UnusedVariableRule and similar to Rust, Python, and GoLang linting rules:

Go treats arguments named _ as dummy arguments.
Rust uses the same rule for unused variables and function params. Python's ruff uses _prefix for unused-function-argument

Fixes phpstan/phpstan#15480

Comment thread tests/PHPStan/Rules/Functions/data/unused-function-parameters.php Outdated
Comment thread tests/PHPStan/Rules/Functions/data/unused-input-value-flow.php Outdated
Comment thread tests/PHPStan/Rules/Functions/data/unused-input-value-flow.php Outdated
@bpfoley
bpfoley force-pushed the 2.3.x branch 3 times, most recently from aa57bb7 to a4e576f Compare October 18, 2026 13:00
Like variable assignment in UnusedVariableRule and similar to Rust,
Python, and GoLang linting rules:

Go treats arguments named `_` as dummy arguments.
Rust uses the same rule for unused variables and function params.
Python's ruff uses _prefix for unused-function-argument

- https://docs.astral.sh/ruff/rules/unused-function-argument/
- https://doc.rust-lang.org/stable/rustc/lints/listing/warn-by-default.html#unused-variables
- https://tip.golang.org/gopls/analyzers#unusedparams

Fixes phpstan/phpstan#15480
@staabm
staabm merged commit 4ba46aa into phpstan:2.3.x Oct 18, 2026
978 of 979 checks passed
@staabm

staabm commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Thank you!

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.

Suppress function.unusedParameter for params starting with _

2 participants