Benjamin
Benjamin

Reputation: 95

PhpStorm .phtml formatting issue

I have problems with PhpStorm auto formating feature. I can't get it to format <?php if(...): ?> and <?php endif; ?> correctly.

This code for example is perfectly formatted ...

<td class="align-right">
    <?php if ($featureSet->grossPrices): ?>
        <?=$this->e(formatPrice($cartItem->totalGrossPrice / $cartItem->amount))?>
    <?php else: ?>
        <?=$this->e(formatPrice($cartItem->totalNetPrice / $cartItem->amount))?>
    <?php endif; ?>
</td>

... but the autoformatter will change it so it look like this:

<td class="align-right">
    <?php if ($featureSet->grossPrices): ?>
        <?= $this->e(formatPrice($cartItem->totalGrossPrice / $cartItem->amount)) ?><?php else: ?>
        <?= $this->e(formatPrice($cartItem->totalNetPrice / $cartItem->amount)) ?><?php endif; ?>
</td>

Do you have any suggestions? I really love PhpStorm. This is literally the only the only issue I have with it, but it really freaks me out -.-

Upvotes: 1

Views: 362

Answers (1)

Benjamin
Benjamin

Reputation: 95

I found a solution:
In the HTML code style settings the option Keep line breaks was disabled and caused this behavior.
Though I think even with this option turned off it should not align the PHP tags like this.

I submitted an issue to the PhpStorm devs:
https://youtrack.jetbrains.com/issue/WI-44274

Upvotes: 1

Related Questions