Skip to content

Commit

Permalink
Extractor: fix escaping quotes when converting from HEREDOC [Closes #151
Browse files Browse the repository at this point in the history
]
  • Loading branch information
dg committed Jan 17, 2024
1 parent 3162d8d commit 19ac08c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/PhpGenerator/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function prepareReplacements(array $nodes): array
$replacements[] = [
$node->getStartFilePos() - $start,
$node->getEndFilePos() - $start,
$quote . addcslashes($node->value, "\x00..\x1F") . $quote,
$quote . addcslashes($node->value, "\x00..\x1F\"") . $quote,
];
}
} elseif ($node instanceof Node\Scalar\Encapsed) {
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpGenerator/expected/ClassType.from.bodies.expect
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ abstract class Class7

$s3 = "a\n\t{$b}\n\t\t$c"
;
$s3 = "a\n\tb\n\t\tc"
$s4 = "a\n\tb\n\t\tc 'q1' \"q2\""
;
// inline HTML is not supported
?>
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpGenerator/expected/Extractor.bodies.expect
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ abstract class Class7

$s3 = "a\n\t{$b}\n\t\t$c"
;
$s3 = "a\n\tb\n\t\tc"
$s4 = "a\n\tb\n\t\tc 'q1' \"q2\""
;
// inline HTML is not supported
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class Class7

$s3 = "a\n\t{$b}\n\t\t$c"
;
$s3 = "a\n\tb\n\t\tc"
$s4 = "a\n\tb\n\t\tc 'q1' \"q2\""
;
// inline HTML is not supported
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class Class7

$s3 = "a\n\t{$b}\n\t\t$c"
;
$s3 = "a\n\tb\n\t\tc"
$s4 = "a\n\tb\n\t\tc 'q1' \"q2\""
;
// inline HTML is not supported
?>
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpGenerator/fixtures/bodies.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ function complex()
$c
DOC
;
$s3 = <<<'DOC'
$s4 = <<<'DOC'
a
b
c
c 'q1' "q2"
DOC
;
// inline HTML is not supported
Expand Down

0 comments on commit 19ac08c

Please sign in to comment.