Menu

Error Identifier: typeAlias.unresolvableType

← Back to typeAlias.*

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

/**
 * @phpstan-type MyType = string&int
 */
class Foo
{
}

Why is it reported? #

A type alias defined via @phpstan-type contains a type that PHPStan cannot resolve. This happens when the type evaluates to an impossible type, such as an intersection of incompatible scalar types, or uses invalid type syntax.

In the example above, string&int is an impossible intersection type – no value can be both a string and an int at the same time. PHPStan cannot resolve this to a meaningful type.

How to fix it #

Replace the unresolvable type with a valid type:

 /**
- * @phpstan-type MyType = string&int
+ * @phpstan-type MyType = string|int
  */
 class Foo
 {
 }

If the intent is to use an intersection type, it must involve compatible types (typically interfaces or classes with an inheritance relationship):

 /**
- * @phpstan-type MyType = string&int
+ * @phpstan-type MyType = Countable&Traversable
  */
 class Foo
 {
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Classes\LocalTypeAliasesRule [1]
  • PHPStan\Rules\Classes\LocalTypeTraitAliasesRule [1]
  • PHPStan\Rules\Classes\LocalTypeTraitUseAliasesRule [1]
Theme
A
© 2026 PHPStan s.r.o.