@@ -884,7 +884,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
884
884
$ done = false ;
885
885
886
886
do {
887
- $ tokens ->skipNewLineTokens ();
887
+ $ tokens ->skipNewLineTokensAndConsumeComments ();
888
888
889
889
if ($ tokens ->tryConsumeTokenType (Lexer::TOKEN_CLOSE_CURLY_BRACKET )) {
890
890
return Ast \Type \ArrayShapeNode::createSealed ($ items , $ kind );
@@ -893,6 +893,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
893
893
if ($ tokens ->tryConsumeTokenType (Lexer::TOKEN_VARIADIC )) {
894
894
$ sealed = false ;
895
895
896
+ $ tokens ->skipNewLineTokensAndConsumeComments ();
896
897
if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_OPEN_ANGLE_BRACKET )) {
897
898
if ($ kind === Ast \Type \ArrayShapeNode::KIND_ARRAY ) {
898
899
$ unsealedType = $ this ->parseArrayShapeUnsealedType ($ tokens );
@@ -936,6 +937,9 @@ private function parseArrayShapeItem(TokenIterator $tokens): Ast\Type\ArrayShape
936
937
$ startLine = $ tokens ->currentTokenLine ();
937
938
$ startIndex = $ tokens ->currentTokenIndex ();
938
939
940
+ // parse any comments above the item
941
+ $ tokens ->skipNewLineTokensAndConsumeComments ();
942
+
939
943
try {
940
944
$ tokens ->pushSavePoint ();
941
945
$ key = $ this ->parseArrayShapeKey ($ tokens );
@@ -973,8 +977,6 @@ private function parseArrayShapeKey(TokenIterator $tokens)
973
977
$ startIndex = $ tokens ->currentTokenIndex ();
974
978
$ startLine = $ tokens ->currentTokenLine ();
975
979
976
- $ tokens ->skipNewLineTokensAndConsumeComments ();
977
-
978
980
if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_INTEGER )) {
979
981
$ key = new Ast \ConstExpr \ConstExprIntegerNode (str_replace ('_ ' , '' , $ tokens ->currentTokenValue ()));
980
982
$ tokens ->next ();
0 commit comments