From e3b74ba8f7004a55c9ece5533bcb5521bbd7ee14 Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Fri, 23 Oct 2026 05:09:13 +0200 Subject: [PATCH 1/5] fix: keep adjacent php blocks separate when there is no text between them --- src/parser.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parser.mjs b/src/parser.mjs index 8df49870d..60a90f850 100644 --- a/src/parser.mjs +++ b/src/parser.mjs @@ -12,6 +12,7 @@ function parse(text, opts) { // Todo https://github.com/glayzzle/php-parser/issues/170 text = text.replace(/\?>\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___<\?/g, "?>___PSEUDO_INLINE_PLACEHOLDER___ Date: Fri, 23 Oct 2026 05:09:15 +0200 Subject: [PATCH 2/5] test: add adjacent block cases --- tests/echo-adjacent/adjacent.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/echo-adjacent/adjacent.php diff --git a/tests/echo-adjacent/adjacent.php b/tests/echo-adjacent/adjacent.php new file mode 100644 index 000000000..68bda1440 --- /dev/null +++ b/tests/echo-adjacent/adjacent.php @@ -0,0 +1,6 @@ + + + + +X + text From a41e0a8a0a8119766534af3ee60e892e06499908 Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Fri, 23 Oct 2026 05:09:18 +0200 Subject: [PATCH 3/5] test: add alternate syntax case --- tests/echo-adjacent/alternate.php | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/echo-adjacent/alternate.php diff --git a/tests/echo-adjacent/alternate.php b/tests/echo-adjacent/alternate.php new file mode 100644 index 000000000..cf7f89aca --- /dev/null +++ b/tests/echo-adjacent/alternate.php @@ -0,0 +1 @@ + From 698be0622beddf8169bde5ca9d063b161785c439 Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Fri, 23 Oct 2026 05:09:20 +0200 Subject: [PATCH 4/5] test: add echo-adjacent spec --- tests/echo-adjacent/jsfmt.spec.mjs | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/echo-adjacent/jsfmt.spec.mjs diff --git a/tests/echo-adjacent/jsfmt.spec.mjs b/tests/echo-adjacent/jsfmt.spec.mjs new file mode 100644 index 000000000..8829c872f --- /dev/null +++ b/tests/echo-adjacent/jsfmt.spec.mjs @@ -0,0 +1 @@ +run_spec(import.meta, ["php"]); From 28ec625cbe728775241bc6dd1b88eafa7b2c884d Mon Sep 17 00:00:00 2001 From: Dextheking1 Date: Fri, 23 Oct 2026 05:09:23 +0200 Subject: [PATCH 5/5] test: add snapshots --- .../__snapshots__/jsfmt.spec.mjs.snap | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/echo-adjacent/__snapshots__/jsfmt.spec.mjs.snap diff --git a/tests/echo-adjacent/__snapshots__/jsfmt.spec.mjs.snap b/tests/echo-adjacent/__snapshots__/jsfmt.spec.mjs.snap new file mode 100644 index 000000000..7b92bf5eb --- /dev/null +++ b/tests/echo-adjacent/__snapshots__/jsfmt.spec.mjs.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`adjacent.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + + + + +X + text + +=====================================output===================================== + + + + +X + text + +================================================================================ +`; + +exports[`alternate.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + + +=====================================output===================================== + + +================================================================================ +`;