Menu

← Back to classConstant.*

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

class Config
{
	/** @var int&string */
	const DEFAULT_TIMEOUT = 30;
}

Why is it reported? #

The @var PHPDoc tag on a class constant contains a type that cannot be resolved. This typically happens when the type is an impossible intersection (like int&string which can never exist), references a non-existent class, or uses invalid type syntax.

In the example above, int&string is an intersection type that can never be satisfied because no value can be both an int and a string at the same time.

How to fix it #

Correct the @var PHPDoc type to use a valid, resolvable type:

 class Config
 {
-	/** @var int&string */
+	/** @var int */
 	const DEFAULT_TIMEOUT = 30;
 }

On PHP 8.3 and later, native typed constants can be used instead of PHPDoc:

<?php declare(strict_types = 1);

class Config
{
	const int DEFAULT_TIMEOUT = 30;
}

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\PhpDoc\IncompatibleClassConstantPhpDocTypeRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.