You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prettier inserts a syntax error when there is a comment after an if statement #2494
This issue only happens when a comment is right after an if statement, and the comment is the last thing inside the php block. Here are examples of cases where the code is formatted correctly:
<?php// example commentif (true): ?>
<h1>Heading</h1>
<?phpendif; ?>
<?php$test = 'Foo';
if (true):
// example comment$test = 'Bar'; ?>
<h1>Heading</h1>
<?phpendif; ?>
Those examples are after they were formatted using the command line prettier.
The second example is somewhat questionable, as I suspect the endif statement should not be moved to a new line - before the formatting happened it was in a single line, like in the first example.
Activity
Pawel-Bakalarz commentedon Apr 15, 2026
Somewhat related issue: #2495