Search code examples
phpcoding-stylephpstorm

PhpStorm indent multi-line array elements


How to configure PhpStorm's PHP coding style settings so this code:

<?php

$array = [
'element1' => 'value1',
'element2' => 'value2',
'element3' => 'value3',
];

Is reformatted like this:

<?php

$array = [
    'element1' => 'value1',
    'element2' => 'value2',
    'element3' => 'value3',
];

Problem is that even if I format arrays like I want, any call to reformat option will "destroy" that formatting and bring me back to unindented elements.

I am interested in short array declaration only.


Solution

  • Based on your current code style: please change Continuation indent from 0 to the desired value (I guess it will be 4, based on your code sample).

    This can be done for all languages at once (General node) or just PHP.