Menu

← Back to typeAlias.*

Error Identifier: typeAlias.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);

/**
 * @phpstan-type Callback callable(Foo): void
 */
class Foo
{
}

Why is it reported? #

A type alias defined via @phpstan-type contains a type that PHPStan cannot fully resolve. This can happen when the type definition references the class it is defined on in a way that creates a circular reference, or when it contains type constructs that lead to resolution issues.

In the example above, the Callback type alias references Foo in a callable parameter, but since the type alias is defined on Foo itself, this creates a circular reference that PHPStan cannot resolve.

How to fix it #

Avoid self-referencing constructs in the type definition:

 /**
- * @phpstan-type Callback callable(Foo): void
+ * @phpstan-type Callback callable(mixed): void
  */
 class Foo
 {
 }

Or define the type alias on a different class that does not create a circular reference.

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]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.