Skip to content

Commit 8390daf

Browse files
committed
fix(parser): not able to parse quoted object shape key correctly
1 parent 437463e commit 8390daf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/phpdoc-parser/parser/type-parser.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ export class TypeParser {
838838
): ConstExprStringNode | IdentifierTypeNode {
839839
const startLine = tokens.currentTokenLine();
840840
const startIndex = tokens.currentTokenIndex();
841-
842841
let key: ConstExprStringNode | IdentifierTypeNode;
842+
843843
if (tokens.isCurrentTokenType(Lexer.TOKEN_SINGLE_QUOTED_STRING)) {
844844
if (this.quoteAwareConstExprString) {
845845
key = new QuoteAwareConstExprStringNode(
@@ -848,12 +848,11 @@ export class TypeParser {
848848
);
849849
} else {
850850
key = new ConstExprStringNode(
851-
tokens.currentTokenValue().replace(/(^"|"$)/g, ''),
851+
tokens.currentTokenValue().replace(/(^'|'$)/g, ''),
852852
);
853853
}
854854
tokens.next();
855-
}
856-
if (tokens.isCurrentTokenType(Lexer.TOKEN_DOUBLE_QUOTED_STRING)) {
855+
} else if (tokens.isCurrentTokenType(Lexer.TOKEN_DOUBLE_QUOTED_STRING)) {
857856
if (this.quoteAwareConstExprString) {
858857
key = new QuoteAwareConstExprStringNode(
859858
StringUnescaper.unescapeString(tokens.currentTokenValue()),
@@ -864,12 +863,12 @@ export class TypeParser {
864863
tokens.currentTokenValue().replace(/(^"|"$)/g, ''),
865864
);
866865
}
867-
868866
tokens.next();
869867
} else {
870868
key = new IdentifierTypeNode(tokens.currentTokenValue());
871869
tokens.consumeTokenType(Lexer.TOKEN_IDENTIFIER);
872870
}
871+
873872
return this.enrichWithAttributes(tokens, key, startLine, startIndex);
874873
}
875874
}

0 commit comments

Comments
 (0)