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:
parent
56918001a8
commit
2fff4eb5c1
@ -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);
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user