plugin-php
plugin-php copied to clipboard
Space before conditional changes closing block
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; ?>