Skip to content

multi-line if statements indent incorrectly #19

Open
@createthis

Description

@createthis

Example:

  if ((1) ||
      (2) ||
        (3)
     ) {
       echo 'foo';
     }

The above is bad because visually it looks like we're still inside the if statement as the indent has changed.

It's also a little messed up in the case of the ) { inline on the third line:

if ((1) ||
    (2) ||
      (3)) {
  echo 'foo';
}

but it gets worse with two lines inside the if:

if (1 ||
    2 ||
      3) {
  echo 'foo';
echo 'bar';
}

and finally, with the bracket on a new line:

if ((1) ||
    (2) ||
      (3))
  {
    echo 'foo';
  }

I would expect these to indent as so:

if ((1) ||
    (2) ||
    (3)
) {
  echo 'foo';
}

if ((1) ||
    (2) ||
    (3)) {
  echo 'foo';
}

if (1 ||
    2 ||
    3) {
  echo 'foo';
  echo 'bar';
}

if ((1) ||
    (2) ||
      (3))
{
  echo 'foo';
}

or like this (possibly configurable):

if ((1) ||
  (2) ||
  (3)
) {
  echo 'foo';
}

if ((1) ||
  (2) ||
  (3)) {
  echo 'foo';
}

if (1 ||
  2 ||
  3) {
  echo 'foo';
  echo 'bar';
}

if ((1) ||
  (2) ||
  (3))
{
  echo 'foo';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions