Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created July 17, 2014 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbachhuber/8934c3c4103389550b43 to your computer and use it in GitHub Desktop.
Save danielbachhuber/8934c3c4103389550b43 to your computer and use it in GitHub Desktop.

The indentation section says:

Your indentation should always reflect logical structure.

I believe this statement makes assumptions, and would be best backed up with examples. I’d propose:

Your indentation should always reflect logical structure. As a rule of thumb, indent the line following an opening tag.

This code has no indentation:

function do_stuff() {
if ( condition ) { ?>
<ul>
<li>something1</li>
<li>something2</li>
</ul>
<?php }
}

This code is inconsistently indented:

function do_stuff() {
    if ( condition ) { ?>
<ul>
<li>something1</li>
    <li>something2</li>
</ul>
    <?php }
}

This code is correctly indented:

function do_stuff() {
    if ( condition ) { ?> 
        <ul>
            <li>something1</li>
            <li>something2</li>
        </ul>
    <?php }
}
@DrewAPicture
Copy link

I agree about adding indentation examples to the coding standards. Of course if we use mixed PHP/HTML, we'll also have to decide one way or the other on same-line or new-line PHP tags as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment