Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm switch statement 'break' indenting

PHPStorm is a very nice IDE, but it does one thing that annoys me.

I (and my team) write our switch statements like so:

switch ($foo) {
    case 'a' :
        // some code
    break;
}

PHPStorm auto-corrects this to be

switch ($foo) {
    case 'a' :
        // some code
        break;
}

Note that the break is indented along with the code. I don't want this to happen.

I've looked in the code style section, but the only option for switches is to indent the case branches.

Does anyone know how stop PHPStorm from doing this?

like image 567
Grim... Avatar asked Aug 17 '13 22:08

Grim...


2 Answers

You can change this default behavior in

settings | Editor | Code Style | PHP | Wrapping and Braces

uncheck indent 'break' from 'case' option

like image 114
A.B.Developer Avatar answered Oct 19 '22 10:10

A.B.Developer


Based on the recommendations in PSR-2 on code style, PHPStorm displays it the recommended way.

If you really want to change it, you can do it in Editor > Code style > PHP > Wrapping and Braces under the 'switch' statement and uncheck the Indent 'break' from 'case.

Disclaimer, the screenshot is from IntelliJ, but you should be able to find the same setting in the same location Related screenshot

like image 36
JF Dion Avatar answered Oct 19 '22 11:10

JF Dion