Menu

Error Identifier: return.unresolvableType

← Back to return.*

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

class Foo {}
class Bar {}

class MyClass
{
	/**
	 * @return Foo&Bar
	 */
	public function get()
	{
		return new Foo();
	}
}

Why is it reported? #

The PHPDoc @return tag contains a type that PHPStan cannot resolve. This happens when the type evaluates to an impossible type, uses invalid type syntax, or references types that create contradictions.

In the example above, Foo&Bar is an intersection type, but since Foo and Bar are unrelated classes (neither extends the other), no value can be both Foo and Bar at the same time. PHPStan resolves this to an impossible type and reports it as unresolvable.

How to fix it #

Use a valid return type. If the method should return an object implementing multiple interfaces, use interface types:

+interface FooInterface {}
+interface BarInterface {}
+
 class MyClass
 {
 	/**
-	 * @return Foo&Bar
+	 * @return FooInterface&BarInterface
 	 */
 	public function get()

Or use a concrete type:

 /**
- * @return Foo&Bar
+ * @return Foo
  */
 public function get()

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyHookPhpDocTypeRule [1]
Theme
A
© 2026 PHPStan s.r.o.