@@ -37,17 +37,22 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode
3737if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
3838$ type = $ this ->tryParseArray ($ tokens , $ type );
3939}
40-
4140} elseif ($ tokens ->tryConsumeTokenType (Lexer::TOKEN_THIS_VARIABLE )) {
42- return new Ast \Type \ThisTypeNode ();
41+ $ type = new Ast \Type \ThisTypeNode ();
4342
43+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
44+ $ type = $ this ->tryParseArray ($ tokens , $ type );
45+ }
4446} else {
4547$ type = new Ast \Type \IdentifierTypeNode ($ tokens ->currentTokenValue ());
4648$ tokens ->consumeTokenType (Lexer::TOKEN_IDENTIFIER );
4749
4850if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_ANGLE_BRACKET )) {
4951$ type = $ this ->parseGeneric ($ tokens , $ type );
5052
53+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
54+ $ type = $ this ->tryParseArray ($ tokens , $ type );
55+ }
5156} elseif ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_PARENTHESES )) {
5257$ type = $ this ->tryParseCallable ($ tokens , $ type );
5358
@@ -56,6 +61,10 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode
5661
5762} elseif ($ type ->name === 'array ' && $ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_CURLY_BRACKET ) && !$ tokens ->isPrecededByHorizontalWhitespace ()) {
5863$ type = $ this ->parseArrayShape ($ tokens , $ type );
64+
65+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
66+ $ type = $ this ->tryParseArray ($ tokens , $ type );
67+ }
5968}
6069}
6170
@@ -101,6 +110,10 @@ private function parseNullable(TokenIterator $tokens): Ast\Type\TypeNode
101110$ type = $ this ->parseArrayShape ($ tokens , $ type );
102111}
103112
113+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
114+ $ type = $ this ->tryParseArray ($ tokens , $ type );
115+ }
116+
104117return new Ast \Type \NullableTypeNode ($ type );
105118}
106119
@@ -179,6 +192,10 @@ private function parseCallableReturnType(TokenIterator $tokens): Ast\Type\TypeNo
179192}
180193}
181194
195+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_SQUARE_BRACKET )) {
196+ $ type = $ this ->tryParseArray ($ tokens , $ type );
197+ }
198+
182199return $ type ;
183200}
184201
@@ -218,7 +235,7 @@ private function tryParseArray(TokenIterator $tokens, Ast\Type\TypeNode $type):
218235}
219236
220237
221- private function parseArrayShape (TokenIterator $ tokens , Ast \Type \TypeNode $ type ): Ast \Type \TypeNode
238+ private function parseArrayShape (TokenIterator $ tokens , Ast \Type \TypeNode $ type ): Ast \Type \ArrayShapeNode
222239{
223240$ tokens ->consumeTokenType (Lexer::TOKEN_OPEN_CURLY_BRACKET );
224241$ tokens ->tryConsumeTokenType (Lexer::TOKEN_PHPDOC_EOL );
0 commit comments