Stop PhpStorm from aligning associative arrays

MikO picture MikO · Apr 22, 2015 · Viewed 18.2k times · Source

How can I tell PhpStorm (using version 8.0.3) to keep the following array as is when clicking Cmd+Alt+L to reformat my code:

$array = [
    'short' => 1, // I want this...
    'veryVeryVeryIncrediblyLong' => 123456789,
];

Instead of doing this:

$array = [
    'short'                      => 1, // Not this...
    'veryVeryVeryIncrediblyLong' => 123456789,
];

Answer

LazyOne picture LazyOne · Apr 22, 2015

Settings (Preferences on Mac) | Editor | Code Style | PHP | Other | Array declaration style -> Align key-value pairs

enter image description here


Since PhpStorm 2017.x version it is now located at Settings (Preferences on Mac) | Editor | Code Style | PHP | Wrapping and Braces --> Array initializer | Align key-value pairs

enter image description here