Menu

← Back to return.*

Error Identifier: return.unresolvableNativeType

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
{
}

function doFoo(): Foo&Bar
{
}

Why is it reported? #

The native return type declaration contains an intersection type that cannot be resolved to a valid type. This typically happens when the intersection of the specified types results in an impossible type – for example, intersecting two classes where neither extends the other.

PHP allows writing intersection types in native type declarations starting with PHP 8.1, but PHPStan validates that the resulting type is logically possible.

This error is non-ignorable because it represents a type that can never be satisfied at runtime.

How to fix it #

Fix the return type to use a valid type that can actually exist.

-function doFoo(): Foo&Bar
+function doFoo(): Foo
 {
 }

If an intersection type is needed, ensure the types are compatible (e.g., a class and an interface):

-function doFoo(): Foo&Bar
+function doFoo(): Foo&SomeInterface
 {
 }

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Functions\ExistingClassesInArrowFunctionTypehintsRule [1] [2]
  • PHPStan\Rules\Functions\ExistingClassesInClosureTypehintsRule [1] [2]
  • PHPStan\Rules\Functions\ExistingClassesInTypehintsRule [1] [2]
  • PHPStan\Rules\Methods\ExistingClassesInTypehintsRule [1] [2]
  • PHPStan\Rules\Properties\ExistingClassesInPropertyHookTypehintsRule [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.