4

I have followed 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 code sniffer, I get 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've tried to find any standards or descriptions about php constructions in html views, but nothing about it's.

Maybe, anybody knows how should looks if and foreach instructions in html?

Thanks.

joni jones
  • 2,865
  • 3
  • 23
  • 28

1 Answers1

1

I fixed my problem, but code looks not pretty 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 views files to Code Sniffer ignore list with @codingStandardsIgnoreFile annotation. Now, need to manually check code style, but code looks much better.

joni jones
  • 2,865
  • 3
  • 23
  • 28