18

I need these chunks of code to be indented properly like this:

$this->render('rights', array(
    'admin' => $admin,
    'editor' => $editor,
    'author' => $author,
));

and widget snippet:

<?php $this->widget('zii.widgets.CMenu', array(
    'items' => array(
        array('label' => 'label', 'url' => 'url')
    )
)); ?>

With default PHPStorm settings it indents this code like this:

$this->render('rights', array(
                             'admin' => $admin,
                             'editor' => $editor,
                             'author' => $author,
                        ));

I went to Settings->Code Style->Wrapping and Braces and changed following options:

  • Array initializer -> Align when multiple (uncheck)
  • Method call arguments -> Align when multiple (uncheck)

The result is:

$this->render('rights', array(
        'admin' => $admin,
        'editor' => $editor,
        'author' => $author,
    ));

Still not the style I want, but that's all I managed to accomplish. Can you please point me to the option I need to change?

0

4 Answers 4

27

Try selecting all the code and clicking : Ctrl + Alt + I
It's auto indentation shortcut ...

Sign up to request clarification or add additional context in comments.

4 Comments

New shortcut is Ctrl + Alt + L, which is great for mint users
That did the trick for phpstorm 2016.1 on Windows ☺ How would that be on MacOS?
On MAC it is simply cmd + alt + L
@avn most comfortable
7

It seems a to be a known issue. Please watch/vote or add your comments there.

1 Comment

2016 and I still have this issue 😱
3

I think this will help you in formatting Your code https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/8

1 Comment

Awesome link :)
3

I've found that unchecking the following option solves the issue for me:

Preferences > Editor > Code Style > PHP > Tab 'Wrapping and Braces' > Function/constructor call arguments > Align when multiline

This changes the following code:

var $numbers = $this->thing(array(
                                "one",
                                "two",
                                "three",
                                "four",
                                "five",
                                "six"
                            ));

To be formatted like:

var $numbers = $this->thing(array(
    "one",
    "two",
    "three",
    "four",
    "five",
    "six"
));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.