PhpStorm .phtml 格式问题
PhpStorm .phtml formatting issue
我在使用 PhpStorm 自动格式化功能时遇到问题。我无法正确格式化 <?php if(...): ?>
和 <?php endif; ?>
。
例如,此代码的格式非常完美...
<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>
...但自动格式化程序会将其更改为如下所示:
<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>
你有什么建议吗?我真的很喜欢 PhpStorm。这实际上是我唯一遇到的唯一问题,但它真的让我很害怕 -.-
我找到了解决方案:
在 HTML 代码样式设置中,选项 Keep line breaks
被禁用并导致了此行为。
虽然我认为即使关闭此选项也不应该像这样对齐 PHP 标签。
我向 PhpStorm 开发人员提交了一个问题:
https://youtrack.jetbrains.com/issue/WI-44274
我在使用 PhpStorm 自动格式化功能时遇到问题。我无法正确格式化 <?php if(...): ?>
和 <?php endif; ?>
。
例如,此代码的格式非常完美...
<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>
...但自动格式化程序会将其更改为如下所示:
<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>
你有什么建议吗?我真的很喜欢 PhpStorm。这实际上是我唯一遇到的唯一问题,但它真的让我很害怕 -.-
我找到了解决方案:
在 HTML 代码样式设置中,选项 Keep line breaks
被禁用并导致了此行为。
虽然我认为即使关闭此选项也不应该像这样对齐 PHP 标签。
我向 PhpStorm 开发人员提交了一个问题:
https://youtrack.jetbrains.com/issue/WI-44274