Skip to content

Commit 3f0f728

Browse files
committed
Revert "wip?"
This reverts commit ba73b1142c93b4d564de529ca8a074efae4ba1d4.
1 parent ac871af commit 3f0f728

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Parser/TypeParser.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
884884
$done = false;
885885

886886
do {
887-
$tokens->skipNewLineTokens();
887+
$tokens->skipNewLineTokensAndConsumeComments();
888888

889889
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
890890
return Ast\Type\ArrayShapeNode::createSealed($items, $kind);
@@ -893,6 +893,7 @@ private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type,
893893
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) {
894894
$sealed = false;
895895

896+
$tokens->skipNewLineTokensAndConsumeComments();
896897
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) {
897898
if ($kind === Ast\Type\ArrayShapeNode::KIND_ARRAY) {
898899
$unsealedType = $this->parseArrayShapeUnsealedType($tokens);
@@ -936,6 +937,9 @@ private function parseArrayShapeItem(TokenIterator $tokens): Ast\Type\ArrayShape
936937
$startLine = $tokens->currentTokenLine();
937938
$startIndex = $tokens->currentTokenIndex();
938939

940+
// parse any comments above the item
941+
$tokens->skipNewLineTokensAndConsumeComments();
942+
939943
try {
940944
$tokens->pushSavePoint();
941945
$key = $this->parseArrayShapeKey($tokens);
@@ -973,8 +977,6 @@ private function parseArrayShapeKey(TokenIterator $tokens)
973977
$startIndex = $tokens->currentTokenIndex();
974978
$startLine = $tokens->currentTokenLine();
975979

976-
$tokens->skipNewLineTokensAndConsumeComments();
977-
978980
if ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) {
979981
$key = new Ast\ConstExpr\ConstExprIntegerNode(str_replace('_', '', $tokens->currentTokenValue()));
980982
$tokens->next();

0 commit comments

Comments
 (0)