Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9e0ab4e

Browse files
Add feature toggle
1 parent 05ccfb7 commit 9e0ab4e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

‎src/Parser/ConstExprParser.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class ConstExprParser
2525
'e' => "\x1B",
2626
];
2727

28+
/** @var bool */
29+
private $unescapeStrings;
30+
31+
public function __construct(bool $unescapeStrings = false)
32+
{
33+
$this->unescapeStrings = $unescapeStrings;
34+
}
35+
2836
public function parse(TokenIterator $tokens, bool $trimStrings = false): Ast\ConstExpr\ConstExprNode
2937
{
3038
if ($tokens->isCurrentTokenType(Lexer::TOKEN_FLOAT)) {
@@ -42,7 +50,11 @@ public function parse(TokenIterator $tokens, bool $trimStrings = false): Ast\Con
4250
if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING, Lexer::TOKEN_DOUBLE_QUOTED_STRING)) {
4351
$value = $tokens->currentTokenValue();
4452
if ($trimStrings) {
45-
$value = self::unescapeString($value);
53+
if ($this->unescapeStrings) {
54+
$value = self::unescapeString($value);
55+
} else {
56+
$value = substr($value, 1, -1);
57+
}
4658
}
4759
$tokens->next();
4860
return new Ast\ConstExpr\ConstExprStringNode($value);

‎tests/PHPStan/Parser/ConstExprParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp(): void
2929
{
3030
parent::setUp();
3131
$this->lexer = new Lexer();
32-
$this->constExprParser = new ConstExprParser();
32+
$this->constExprParser = new ConstExprParser(true);
3333
}
3434

3535

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /