diff --git a/src/comments.mjs b/src/comments.mjs index bc1b8a643..cc1b61524 100644 --- a/src/comments.mjs +++ b/src/comments.mjs @@ -691,6 +691,16 @@ function handleInlineComments( ) { addDanglingComment(precedingNode, comment); return true; + } else if ( + precedingNode && + precedingNode.kind === "inline" && + followingNode + ) { + // A comment right after the open tag (`?>... + + + + + + + +=====================================output===================================== +
+ +
+ + + + + +================================================================================ +`; + +exports[`inline-short-form-elseif.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + +

a

+ + + +

c

+ + +=====================================output===================================== + +

a

+ + + +

c

+ + +================================================================================ +`; + +exports[`inline-short-form-if.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + +

a

+ + + + +=====================================output===================================== + +

a

+ + + + +================================================================================ +`; + exports[`inline2.php 1`] = ` ====================================options===================================== parsers: ["php"] @@ -4627,8 +4727,7 @@ printWidth: 80 echo "foo"; ?> + echo "bar"; ?> ================================================================================ `; diff --git a/tests/comments/inline-open-tag-comment.php b/tests/comments/inline-open-tag-comment.php new file mode 100644 index 000000000..1935c680b --- /dev/null +++ b/tests/comments/inline-open-tag-comment.php @@ -0,0 +1,9 @@ +
+ +
+ + + + diff --git a/tests/comments/inline-short-form-elseif.php b/tests/comments/inline-short-form-elseif.php new file mode 100644 index 000000000..d18b87732 --- /dev/null +++ b/tests/comments/inline-short-form-elseif.php @@ -0,0 +1,11 @@ + +

a

+ + + +

c

+ diff --git a/tests/comments/inline-short-form-if.php b/tests/comments/inline-short-form-if.php new file mode 100644 index 000000000..50bcb2c4e --- /dev/null +++ b/tests/comments/inline-short-form-if.php @@ -0,0 +1,12 @@ + +

a

+ + +