Menu

Error Identifier: function.unusedParameter

← Back to function.*

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

function doFoo(int $value, string $unused): void
{
	echo $value;
}

Why is it reported? #

The function declares the parameter $unused but never reads it in its body. A parameter that no code path uses is dead — it either signals a leftover from refactoring or a mistake where the parameter was meant to be used.

Unlike methods, a plain function has no interface, parent, or override that could dictate its signature, so an unused parameter is always safe to remove. Parameters referenced by a @phpstan-assert tag or a conditional return type are not reported, since they serve the call site.

This rule is part of PHPStan’s dead code analysis. It is reported at rule level 4 and above, and is currently part of Bleeding Edge.

How to fix it #

Remove the unused parameter:

-function doFoo(int $value, string $unused): void
+function doFoo(int $value): void
 {
 	echo $value;
 }

Or use the parameter in the function body if it was intended to be read:

 function doFoo(int $value, string $unused): void
 {
 	echo $value;
+	echo $unused;
 }

How to ignore this error #

You can use the identifier function.unusedParameter to ignore this error using a comment:

// @phpstan-ignore function.unusedParameter
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: function.unusedParameter

Rules that report this error #

  • PHPStan\Rules\Classes\UnusedConstructorParametersRule [1]
  • PHPStan\Rules\Functions\UnusedFunctionParametersRule [1]
  • PHPStan\Rules\Methods\UnusedMethodParametersRule [1]
Theme
A
© 2026 PHPStan s.r.o.