Our team will start to use a formatter for PHP. We decided the easiest way was to use an already existing standard and decided for PSR-12.
Half the team uses VSCode and the extension Intelephense for formatting. The other half uses PhpStorm and the built in formatter with the PSR-12 preset.
Some modifications had to be made in PhpStorm to behave the same as the VSCode formatter. This because the VSCode extension requires Premium to change formatting preferences.
However there is one problem remaining.
PhpStorm indents a wrapped line after context, do not know how else to describe it. As can be seen in the snippet below there are 8 spaces before the string in the array and 4 spaces before the closing bracket.
if (1 && [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
]) {
}
If I remove the first argument (1) the indentation becomes correct
if ([
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
]) {
}
When formatting with VSCode, this is the result
if (1 && [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
]) {
}
I have read through the PhpStorm formatting settings multiple times and been searching the web for similar problems but I am nowhere closer to fixing this.
Am I missing a setting or do you have any other recommendations?
Following section of PSR-12 states:
Therefore, the correct formatting of your line would be: