graille
graille

Reputation: 1231

PhpStorm code formatter and indentation

I'm using PhpStorm with Symfony 3 to write my project.

But I've an issue. When I reformat the code,

This code :

enter image description here

Turns into this code :

enter image description here

And I don't know what is the setting I have to change to fix that :/ Any idea?

Upvotes: 1

Views: 1180

Answers (2)

rickroyce
rickroyce

Reputation: 1032

I found the solution for this at https://www.jetbrains.com/help/phpstorm/reformat-and-rearrange-code.html

First enable formatter markers in Settings->Editor->Tab:Formatter Control

After that, you can switch on/off the formatter on every statement/docblock via

// @formatter:off

or

/**
 * @formatter:off
 */

be sure, that you enable the formatter with // @formatter:on if you want to format the code below your chained method call.

Upvotes: 1

Grene
Grene

Reputation: 434

You change it in Menu:

File -> Default Settings -> Editor -> Code Style -> PHP and overlap: Wrapping and Braces:

Chained method calls : "Wrap always"
  Align when multiline   "Y"
  Place ';' on new Line  "Y"

After it you can reformat yours code CTR+ALT+L

Upvotes: 0

Related Questions