Menu

← Back to paramOut.*

Error Identifier: paramOut.nestedUnusedType

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);

/**
 * @param array<mixed> $a
 * @param-out array<array{int, bool}> $a
 */
function doFoo(array &$a): void
{
	$a = [
		[1, false],
		[2, false],
	];
}

Why is it reported? #

The @param-out type declaration is wider than necessary in a nested part of the type. In the example above, the @param-out type declares array<array{int, bool}>, but the function only ever assigns false to the second element of the inner tuple, never true. The type could be narrowed to array<array{int, false}>.

This is similar to having a too-wide return type, but it applies to by-reference parameter output types and specifically to nested type components within the declared type.

How to fix it #

Narrow the @param-out type to match what the function actually assigns:

 /**
  * @param array<mixed> $a
- * @param-out array<array{int, bool}> $a
+ * @param-out array<array{int, false}> $a
  */
 function doFoo(array &$a): void
 {
 	$a = [
 		[1, false],
 		[2, false],
 	];
 }

How to ignore this error #

You can use the identifier paramOut.nestedUnusedType to ignore this error using a comment:

// @phpstan-ignore paramOut.nestedUnusedType
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: paramOut.nestedUnusedType

Rules that report this error #

  • PHPStan\Rules\TooWideTypehints\TooWideArrowFunctionReturnTypehintRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWideClosureReturnTypehintRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWideFunctionParameterOutTypeRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWideFunctionReturnTypehintRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWideMethodParameterOutTypeRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWideMethodReturnTypehintRule [1]
  • PHPStan\Rules\TooWideTypehints\TooWidePropertyTypeRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.