Skip to content

Commit c2201a2

Browse files
jodysimpsonczosel
authored andcommitted
Fixed heredoc inside function calls inside other function calls (#1064)
1 parent ce8302a commit c2201a2

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ function docShouldHaveTrailingNewline(path) {
258258
}
259259

260260
if (
261-
(parentParent && ["call", "new", "echo"].includes(parentParent.kind)) ||
261+
(parentParent &&
262+
["call", "new", "echo"].includes(parentParent.kind) &&
263+
parent.kind !== "call") ||
262264
parent.kind === "parameter"
263265
) {
264266
const lastIndex = parentParent.arguments.length - 1;

tests/nowdoc/__snapshots__/jsfmt.spec.js.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ foo
5252
EOD
5353
, true);
5454
55+
$str = sprintf(sprintf(<<<END
56+
foo
57+
END
58+
, true));
59+
5560
function foo($a = 1, $b = <<<'EOD'
5661
Example of string
5762
spanning multiple lines
@@ -982,6 +987,16 @@ EOD
982987
true
983988
);
984989
990+
$str = sprintf(
991+
sprintf(
992+
<<<END
993+
foo
994+
END
995+
,
996+
true
997+
)
998+
);
999+
9851000
function foo(
9861001
$a = 1,
9871002
$b = <<<'EOD'

tests/nowdoc/nowdoc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
EOD
4545
, true);
4646

47+
$str = sprintf(sprintf(<<<END
48+
foo
49+
END
50+
, true));
51+
4752
function foo($a = 1, $b = <<<'EOD'
4853
Example of string
4954
spanning multiple lines

0 commit comments

Comments
 (0)