mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-06-05 03:24:50 +02:00
Strip trailing doc string newline before parsing escape sequences
If the doc string ends on an escaped \r, it should not get eaten as the "last newline".
This commit is contained in:
parent
4c3e759a51
commit
c62dda9507
@ -823,10 +823,10 @@ abstract class ParserAbstract implements Parser {
|
||||
$part->value, $indentLen, $indentChar,
|
||||
$i === 0, $isLast, $part->getAttributes()
|
||||
);
|
||||
$part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
|
||||
if ($isLast) {
|
||||
$part->value = preg_replace('~(\r\n|\n|\r)\z~', '', $part->value);
|
||||
}
|
||||
$part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
|
||||
if ('' === $part->value) {
|
||||
continue;
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ b<<<EOS
|
||||
Binary
|
||||
EOS;
|
||||
|
||||
<<<EOS
|
||||
$x\r
|
||||
EOS;
|
||||
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Expression(
|
||||
@ -112,4 +116,16 @@ array(
|
||||
value: Binary
|
||||
)
|
||||
)
|
||||
7: Stmt_Expression(
|
||||
expr: Scalar_InterpolatedString(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: x
|
||||
)
|
||||
1: InterpolatedStringPart(
|
||||
value:
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user