Fuzzy code write-off errors
I followed the html markup with php code:
<div class="block">
<div class="block-title">
<?php if ($user->isOnline()): ?>
<a href="<?=Url::create('/user/logout');?>">Logout</a>
<?php endif; ?>
</div>
</div>
When I run the code sniffer, I get the following errors:
<error line="3" column="15" severity="error" message="Line indented incorrectly; expected 8 spaces, found 0" source="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
<error line="5" column="15" severity="error" message="Closing brace must be on a line by itself" source="PEAR.WhiteSpace.ScopeClosingBrace.Line"/>
I tried to find any standards or descriptions about php constructs in html views, but there was nothing about it.
Maybe someone knows how you like instructions ifand foreachin html?
Thanks.
+4
1 answer
I fixed my problem, but the code does not look very good:
<div class="block">
<div class="block-title">
<?php
if ($user->isOnline()): ?>
<a href="<?=Url::create('/user/logout');?>">Logout</a>
<?php
endif; ?>
</div>
So I decided to add view files to the Sniffer code ignore list with annotation @codingStandardsIgnoreFile. Now you need to manually check the style of the code, but the code looks much better.
+1