From 2302fb0dc030c622bda1646fcccbe3f022bf724d Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Thu, 24 Sep 2026 12:26:24 +0200 Subject: [PATCH 1/2] fix: strip pseudo inline placeholder from string/heredoc/nowdoc output parser.mjs injects ___PSEUDO_INLINE_PLACEHOLDER___ into the source text for top-level ?>\n\n i > 0 || node.loc.start.column === 0 @@ -2746,7 +2766,7 @@ function printNode(path, options, print) { const quote = useDoubleQuote(node, options) ? '"' : "'"; - let stringValue = node.raw; + let stringValue = node.raw.replaceAll(PSEUDO_INLINE_PLACEHOLDER, ""); if (node.raw[0] === "b") { stringValue = stringValue.slice(1); @@ -2811,7 +2831,7 @@ function printNode(path, options, print) { case "inline": return join( literalline, - node.raw.replace("___PSEUDO_INLINE_PLACEHOLDER___", "").split("\n") + node.raw.replaceAll(PSEUDO_INLINE_PLACEHOLDER, "").split("\n") ); case "magic": return node.value; @@ -2823,7 +2843,14 @@ function printNode(path, options, print) { node.label, "'", linebreak, - join(linebreak, node.value.split("\n")), + // The parser injects `___PSEUDO_INLINE_PLACEHOLDER___` into the raw + // source text for top-level `?>\n + + + + +EOD; +} + +$nowdoc = <<<'EOD' + + +EOD; + +$string = "\\n"; + +=====================================output===================================== + + + + + + EOD; +} +$nowdoc = <<<'EOD' + + +EOD; +$string = "\\n"; + +================================================================================ +`; diff --git a/tests/heredoc/heredoc.php b/tests/heredoc/heredoc.php new file mode 100644 index 000000000..716deadd7 --- /dev/null +++ b/tests/heredoc/heredoc.php @@ -0,0 +1,19 @@ + + + + + +EOD; +} + +$nowdoc = <<<'EOD' + + +EOD; + +$string = "\n"; diff --git a/tests/heredoc/jsfmt.spec.mjs b/tests/heredoc/jsfmt.spec.mjs new file mode 100644 index 000000000..8829c872f --- /dev/null +++ b/tests/heredoc/jsfmt.spec.mjs @@ -0,0 +1 @@ +run_spec(import.meta, ["php"]); From 4a9bb5bfc0c92cf6f105f1a6015be1e9cc257115 Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Mon, 28 Sep 2026 02:29:44 +0200 Subject: [PATCH 2/2] fix: strip pseudo inline placeholder in clean.mjs for AST_COMPARE parser.mjs injects ___PSEUDO_INLINE_PLACEHOLDER___ into the source text for top-level ?> newline \n continue 2; // continue 1; -> continue; if ((node.kind === "continue" || node.kind === "break") && node.level) {