Menu
Error Identifier: typeAlias.invalidType
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 array{name: string, value: }
*/
class Foo
{
}
Why is it reported? #
A type alias defined via @phpstan-type contains a type definition that cannot be parsed. The type syntax in the alias is malformed or uses unsupported constructs, resulting in an error type that PHPStan cannot resolve.
Common causes include:
- Syntax errors in the type definition (missing parts, extra commas, unclosed brackets)
- Using type syntax that PHPStan does not recognize
How to fix it #
Correct the type definition syntax in the @phpstan-type tag:
<?php declare(strict_types = 1);
/**
- * @phpstan-type MyType array{name: string, value: }
+ * @phpstan-type MyType array{name: string, value: mixed}
*/
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