prettier / prettier/plugin-php
Space before conditional changes closing block
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
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; ?>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the formatter behavior from the linked Playground using the provided PHP input and compare it with the expected output. Trace the plugin's handling of conditional closing blocks when text precedes the opening PHP tag; done means the closing <?php endif; ?> remains on one line and the workaround still formats as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100