Skip to content

Commit ae5be81

Browse files
committed
Use StringUnescaper when quoteAwareConstExprString=true
1 parent 376023a commit ae5be81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Parser/TypeParser.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,15 @@ private function parseArrayShapeKey(TokenIterator $tokens)
576576

577577
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
578578
if ($this->quoteAwareConstExprString) {
579-
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(trim($tokens->currentTokenValue(), "'"), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
579+
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
580580
} else {
581581
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), "'"));
582582
}
583583
$tokens->next();
584584

585585
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) {
586586
if ($this->quoteAwareConstExprString) {
587-
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(trim($tokens->currentTokenValue(), '"'), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
587+
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
588588
} else {
589589
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), '"'));
590590
}
@@ -645,15 +645,15 @@ private function parseObjectShapeKey(TokenIterator $tokens)
645645
{
646646
if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
647647
if ($this->quoteAwareConstExprString) {
648-
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(trim($tokens->currentTokenValue(), "'"), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
648+
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::SINGLE_QUOTED);
649649
} else {
650650
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), "'"));
651651
}
652652
$tokens->next();
653653

654654
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) {
655655
if ($this->quoteAwareConstExprString) {
656-
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(trim($tokens->currentTokenValue(), '"'), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
656+
$key = new Ast\ConstExpr\QuoteAwareConstExprStringNode(StringUnescaper::unescapeString($tokens->currentTokenValue()), Ast\ConstExpr\QuoteAwareConstExprStringNode::DOUBLE_QUOTED);
657657
} else {
658658
$key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), '"'));
659659
}

0 commit comments

Comments
 (0)