Menu

Error Identifier: function.unusedParameterFlow

← 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 $input): void
{
	while (rand(0, 1)) {
		$input = $input + 1;
	}
}

Why is it reported? #

The function’s parameter $input is read — but only by $input = $input + 1, whose result no code ever observes. The parameter’s value feeds a closed computation that produces nothing.

This is different from function.unusedParameter, where the parameter is never read at all. Here the value flows through further computation, but that computation is itself dead, so the parameter has no effect on the program. This usually points to a leftover from refactoring or a logic error where the parameter was meant to be used.

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 parameter and the dead computation if the result is not needed:

-function doFoo(int $input): void
+function doFoo(): void
 {
-	while (rand(0, 1)) {
-		$input = $input + 1;
-	}
 }

Or use the computed value for something observable if that was the intent:

 function doFoo(int $input): void
 {
 	while (rand(0, 1)) {
 		$input = $input + 1;
 	}
+	echo $input;
 }

How to ignore this error #

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

// @phpstan-ignore function.unusedParameterFlow
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.unusedParameterFlow

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.