Menu

← Back to argument.*

Error Identifier: argument.unresolvableType

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

/**
 * @template T
 * @param T[] $items
 * @return T|null
 */
function firstOrNull(array $items): mixed
{
	return count($items) > 0 ? $items[0] : null;
}

function doFoo(mixed $list): void
{
	$first = firstOrNull($list);
}

Why is it reported? #

PHPStan reports this error when calling a generic function or method and it cannot resolve the template type from the provided arguments. Generic functions declare template types via @template PHPDoc tags, and the return type depends on what gets passed as arguments.

In the example above, firstOrNull expects T[] so that it can resolve T. When mixed is passed instead of a specific array type, PHPStan cannot determine what T is. To prevent mixed from being propagated further, PHPStan reports this error and asks for a more specific argument.

Learn more: Solving PHPStan error “Unable to resolve the template type”

How to fix it #

Pass a more specific type so that PHPStan can resolve the template type from the argument:

-function doFoo(mixed $list): void
+/** @param int[] $list */
+function doFoo(array $list): void
 {
 	$first = firstOrNull($list);
 }

How to ignore this error #

You can use the identifier argument.unresolvableType to ignore this error using a comment:

// @phpstan-ignore argument.unresolvableType
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: argument.unresolvableType

Rules that report this error #

  • PHPStan\Rules\Classes\ClassAttributesRule [1]
  • PHPStan\Rules\Classes\ClassConstantAttributesRule [1]
  • PHPStan\Rules\Classes\InstantiationRule [1]
  • PHPStan\Rules\Constants\ConstantAttributesRule [1]
  • PHPStan\Rules\EnumCases\EnumCaseAttributesRule [1]
  • PHPStan\Rules\Functions\ArrowFunctionAttributesRule [1]
  • PHPStan\Rules\Functions\CallCallablesRule [1]
  • PHPStan\Rules\Functions\CallToFunctionParametersRule [1]
  • PHPStan\Rules\Functions\CallUserFuncRule [1]
  • PHPStan\Rules\Functions\ClosureAttributesRule [1]
  • PHPStan\Rules\Functions\FunctionAttributesRule [1]
  • PHPStan\Rules\Functions\ParamAttributesRule [1]
  • PHPStan\Rules\Methods\CallMethodsRule [1]
  • PHPStan\Rules\Methods\CallStaticMethodsRule [1]
  • PHPStan\Rules\Methods\MethodAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyHookAttributesRule [1]
  • PHPStan\Rules\Traits\TraitAttributesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.