diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index b09620fdc..35d3f8764 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -90,7 +90,7 @@ abstract class Atomic implements TypeNode /** * @param array{int,int}|null $php_version * @param array> $template_type_map - * @param array $type_aliases + * @param array $type_aliases */ public static function create( string $value, @@ -277,7 +277,7 @@ abstract class Atomic implements TypeNode return new TTypeAlias($type_alias->declaring_fq_classlike_name, $type_alias->alias_name); } - throw new \UnexpectedValueException('This should never happen'); + throw new \Psalm\Exception\TypeParseTreeException('Invalid type alias ' . $value . ' provided'); } return new TNamedObject($value); diff --git a/tests/TypeAnnotationTest.php b/tests/TypeAnnotationTest.php index 3ae85cd90..aa9aedac0 100644 --- a/tests/TypeAnnotationTest.php +++ b/tests/TypeAnnotationTest.php @@ -521,6 +521,18 @@ class TypeAnnotationTest extends TestCase }', 'error_message' => 'PossiblyUndefinedArrayOffset', ], + 'noCrashWithSelfReferencingType' => [ + ' 'InvalidDocblock', + ], ]; } }