plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Bug with mixture of php with comments and html

Open dmitryostrov opened this issue 11 months ago • 2 comments

Prettier 3.5.3

PHP Plugin 0.22.4

# Options (if any):

Input:

<?php
const a = true;
?><div></div>
<?php if (2==2) {
  // comment
  ?><span></span><?php
  return true;
}

Output:

<?php
const a = true; ?><div></div>
<?php if (2 == 2) {<?php
    // comment
    ?><span></span><?php return true;}

Expected behavior: < ? php above the comment line at the end is not needed

dmitryostrov avatar Mar 19 '25 17:03 dmitryostrov

I ran into the same issue yesturday.

<?php
if ($add_call || $edit_call){
        ?>

<?php
	}  elseif ($add_call || $edit_call) {
 	  // ADD EDIT CALL NOTE form
?>
     <h1> Call Header </h1>
<?php
}
?>

That snippit will format to this:

<?php
if ($add_call || $edit_call) { ?>
<?php } elseif ($add_call || $edit_call) {<?php
    // ADD EDIT CALL NOTE form
    ?>
     <h1> Call Header </h1>
<?php } ?>

vfrunza avatar Apr 02 '25 19:04 vfrunza

From README:

Formatting of files that contain mixed PHP and HTML is still considered unstable

hackel avatar Jun 02 '25 15:06 hackel