Menu

← Back to method.*

Error Identifier: method.unresolvableReturnType

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
 */
class Collection
{
	/**
	 * @param T $item
	 * @return T
	 */
	public function wrap($item)
	{
		return $item;
	}
}

/** @var Collection<string> $collection */
$collection = new Collection();
$result = $collection->wrap(123);

Why is it reported? #

The return type of a method call contains an unresolvable type. This usually happens with generic (templated) methods where the template type cannot be resolved based on the arguments provided. PHPStan cannot determine what the actual return type will be, which reduces the quality of type analysis for subsequent code.

How to fix it #

Ensure that the arguments passed to the method provide enough type information for PHPStan to resolve the template types. This typically means passing arguments that match the expected template parameter types.

 <?php declare(strict_types = 1);
 
 /** @var Collection<string> $collection */
 $collection = new Collection();
-$result = $collection->wrap(123);
+$result = $collection->wrap('hello');

How to ignore this error #

You can use the identifier method.unresolvableReturnType to ignore this error using a comment:

// @phpstan-ignore method.unresolvableReturnType
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: method.unresolvableReturnType

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.