1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Fix #4653 - prevent crash with recursive type in root namespace

This commit is contained in:
Matt Brown 2020-11-22 00:26:14 -05:00 committed by Daniil Gentili
parent 56918001a8
commit 2fff4eb5c1
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 14 additions and 2 deletions

View File

@ -90,7 +90,7 @@ abstract class Atomic implements TypeNode
/**
* @param array{int,int}|null $php_version
* @param array<string, array<string, array{Union}>> $template_type_map
* @param array<string, TypeAlias> $type_aliases
* @param array<string, TypeAlias\LinkableTypeAlias> $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);

View File

@ -521,6 +521,18 @@ class TypeAnnotationTest extends TestCase
}',
'error_message' => 'PossiblyUndefinedArrayOffset',
],
'noCrashWithSelfReferencingType' => [
'<?php
/**
* @psalm-type SomeType = array{
* parent?: SomeType,
* foo?: int,
* }
* @psalm-param SomeType $input
*/
function test(array $input):void {}',
'error_message' => 'InvalidDocblock',
],
];
}
}