PHP identation of array elements

Identation of php array() is killing me!

For example, when I write this:
PaperlessService::getInstance()->makePayment(array( $caret$ ));

And hit enter, I expect this:
PaperlessService::getInstance()->makePayment(array(
  $caret$
));
However, I get this:
      PaperlessService::getInstance()->makePayment(array(
                                                                                             $caret$
                                                                                            ));


WTF? Is there anything I can do about it?

6 comments
Comment actions Permalink

Anyone? I'm having a hard time with this issue. :_|

0
Comment actions Permalink

Finally, I came across CodeStyle => Wrapping and Braces settings and now it looks almost perfect:

      PaperlessService::getInstance()->makePayment(array(
          $caret$
        ));

My settings:


Method call arguments:
Align when multiline    false
New line after '('    false
Place ')' on new line    true


Array initializer:
Align when multiline    false
New line after '{'    true
Place '}' on new line    true

I'm still missing some conf to disable extra margin before $caret$ and closing brackets:

      PaperlessService::getInstance()->makePayment(array(
        $caret$
      ));

(notice that the braces are exactly under the first statement)

0
Comment actions Permalink

Do you mean an extra line feed? In any case please submit a feature request at http://youtrack.jetbrains.com.

0
Comment actions Permalink

No, I mean, unnecessary extra identation:
PaperlessService::getInstance()->makePayment(array(
    $caret$
<!--extra ident, can't get rid of it-->));

0
Comment actions Permalink

I think it's related to this issue: http://youtrack.jetbrains.net/issue/WI-7471
it has been solved and if you get the latest EAP build, it will give you the following if you press Enter inside array():
<?php

function bar()
{
    PaperlessService::getInstance()->makePayment(array(
        <caret>
    ));
}

Hopefully that's what you want.

0
Comment actions Permalink

Yes! Absolutely. Phoenix Zerin put it much better than me)

0

Please sign in to leave a comment.