mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
parent
b6499c33ed
commit
c8fe9e89f3
@ -50,7 +50,30 @@ class ParseTree
|
||||
switch ($type_token) {
|
||||
case '<':
|
||||
case '{':
|
||||
throw new TypeParseTreeException('Unexpected token');
|
||||
case ']':
|
||||
throw new TypeParseTreeException('Unexpected token ' . $type_token);
|
||||
|
||||
case '[':
|
||||
if ($next_token !== ']') {
|
||||
throw new TypeParseTreeException('Unexpected token ' . $type_token);
|
||||
}
|
||||
|
||||
$current_parent = $current_leaf->parent;
|
||||
|
||||
$new_parent_leaf = new ParseTree\GenericTree('array', $current_parent);
|
||||
$current_leaf->parent = $new_parent_leaf;
|
||||
$new_parent_leaf->children = [$current_leaf];
|
||||
|
||||
if ($current_parent) {
|
||||
array_pop($current_parent->children);
|
||||
$current_parent->children[] = $new_parent_leaf;
|
||||
} else {
|
||||
$parse_tree = $new_parent_leaf;
|
||||
}
|
||||
|
||||
$current_leaf = $new_parent_leaf;
|
||||
++$i;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
do {
|
||||
|
@ -170,6 +170,17 @@ class TypeParseTest extends TestCase
|
||||
$this->assertSame('array<mixed, array<mixed, A|B>>', (string) Type::parseString('(A|B)[][]'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testPhpDocObjectLikeArray()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array<mixed, array{b:bool, d:string}>',
|
||||
(string) Type::parseString('array{b:bool,d:string}[]')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user