mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
parse array{} into an empty array
This commit is contained in:
parent
f5dc2ee964
commit
030195a395
@ -751,6 +751,13 @@ class ParseTreeCreator
|
||||
$new_parent
|
||||
);
|
||||
++$this->t;
|
||||
|
||||
$nexter_token = $this->t + 1 < $this->type_token_count ? $this->type_tokens[$this->t + 1] : null;
|
||||
|
||||
if ($nexter_token !== null && $nexter_token[0] === '}') {
|
||||
$new_leaf->terminated = true;
|
||||
++$this->t;
|
||||
}
|
||||
break;
|
||||
|
||||
case '(':
|
||||
|
@ -1235,7 +1235,7 @@ class TypeParser
|
||||
/**
|
||||
* @param array<string, array<string, Union>> $template_type_map
|
||||
* @param array<string, TypeAlias> $type_aliases
|
||||
* @return TCallableKeyedArray|TKeyedArray|TObjectWithProperties
|
||||
* @return TCallableKeyedArray|TKeyedArray|TObjectWithProperties|TArray
|
||||
* @throws TypeParseTreeException
|
||||
*/
|
||||
private static function getTypeFromKeyedArrayTree(
|
||||
@ -1314,7 +1314,7 @@ class TypeParser
|
||||
}
|
||||
|
||||
if (!$properties) {
|
||||
throw new TypeParseTreeException('No properties supplied for TKeyedArray');
|
||||
return new TArray([Type::getNever(), Type::getNever()]);
|
||||
}
|
||||
|
||||
if ($type === 'object') {
|
||||
|
@ -893,6 +893,14 @@ class TypeParseTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testEmptyArrayShape(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'array<never, never>',
|
||||
(string)Type::parseString('array{}')
|
||||
);
|
||||
}
|
||||
|
||||
public function testSingleLiteralInt(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
|
Loading…
Reference in New Issue
Block a user