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

Space before conditional changes closing block

Open joemaller opened this issue 4 years ago • 0 comments

Having any text characters before the opening <?php causes the closing <?php endif; ?> block to wrap.

@prettier/plugin-php v0.17.4 Playground link

Input:


<?php
$a = 1;
if (true): ?>

text

<?php endif; ?>

Output:


<?php
$a = 1;
if (true): ?>

text

<?php endif;
 ?>

Expected


<?php
$a = 1;
if (true): ?>

text

<?php endif; ?>

As a workaround, putting the opening conditional into it's own block causes the closing block to wrap correctly:


<?php
$a = 1;
?>
<?php if (true): ?>

text

<?php endif; ?>

formats to


<?php $a = 1; ?>
<?php if (true): ?>

text

<?php endif; ?>

joemaller avatar Sep 01 '21 17:09 joemaller