@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Notice that the //end true check comment is inserted next to the comments near the else statement.
However, a weirder things happen when I delete the entire /* My comment */ PHP block:
@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Multiple comments get duplicated
@prettier/plugin-php v0.25.0
Playground link
Input:
Output:
Notice that the
//end true checkcomment is inserted next to the comments near theelsestatement.However, a weirder things happen when I delete the entire
/* My comment */PHP block:@prettier/plugin-php v0.25.0
Playground link
Input:
Output:
Multiple comments get duplicated