Menu
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 int<0>
*/
class Foo
{
}
Why is it reported? #
A type alias defined via @phpstan-type contains a type definition that resolves to an invalid type. While the type syntax may be parseable, it produces an error type that PHPStan cannot work with.
Common causes include:
- Using invalid generic type arguments (e.g.
int<0>instead ofint<0, max>) - Type definitions that resolve to impossible or contradictory types
How to fix it #
Correct the type definition in the @phpstan-type tag:
/**
- * @phpstan-type MyType int<0>
+ * @phpstan-type MyType int<0, max>
*/
class Foo
{
}
How to ignore this error #
You can use the identifier typeAlias.invalidType to ignore this error using a comment:
// @phpstan-ignore typeAlias.invalidType
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.invalidType