PhpStorm short tags indentation (if/endif)
-
04-12-2019 - |
Question
Here is the indentation that PhpStorm will generate for this code:
<?php if (count($foo) > 0) : ?>
<div>...</div>
<?php else : ?>
<p>...</p>
<?php endif; ?>
Is that supposed to be the wanted PHP indentation when mixing if/for/... blocks with HTML or is it a bug with the short tags?
I am talking about PhpStorm default formatting style. I am wondering if this behavior is intended by PhpStorm or a bug.
Solution
The final answer is that is a bug, if you expect (as anyone would I guess) the content of the if
to be indented.
I filed a bug: http://youtrack.jetbrains.com/issue/WI-11118.
OTHER TIPS
@Marc B is actually spot on with why PHPStorm is doing it this way by default. There is no standard and therefore the PHPStorm authors just chose whatever they wanted by default and gave you settings where you can configure it do be however you want.
To answer your specific question though, it's not a bug, because there's no correct way for it to be. It's all personal preference.