PhpStorm code format inserts space

I have a maddening issue with PhpStorm code reformat. I'm working on a WordPress project which uses the WordPress code standard for phpcs. One of the things the standard doesn't like is "precision alignment", where spaces are used to line things up more exactly. According to this standard, everything must be aligned on tab stops.

I start with a nicely tabbed bit of code like the top screenshot. But when I run the PhpStorm code formatter, it inserts a single space before the continuation line (before `$ids['review_id']` in this example), so phpcs warns `Found precision alignment of 1 spaces`.


My PHP code style settings are like this:

I have an `.editorconfig`, but I don't see anything dodgy in there:

root = true

charset = utf-8
end_of_line = lf
indent_size = 4
tab_width = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

trim_trailing_whitespace = false

trim_trailing_whitespace = false
indent_style = space
indent_size = 2

Has anyone else come across this problem?


Basically, I was not able to reproduce your reformatting result but it looks even worse in my case. On default settings, this example:

turns into this:

By the way, do you have "Code Style > PHP > Wrapping and braces > Array initializer > Align key-value pairs" enabled?

Would it be possible to share the whole example as a code snippet and exported code style settings (XML)? 


Hi Vasiliy, thanks for having a look! 👌 Sure – I can't share my whole file, so I've deleted all the methods except the one, without changing the indents.

Download link (expires in 24 hours): 



Thanks for leaving a link.

Unfortunately, there is no code example, only IDE settings, sorry. Also, I see three IDE-based code styles in that settings, which exactly do you use?

Is there any chance that you have a Project-based code style setting? I am asking this as it will not be exported with "" file. However, it is possible to export it via the Code Style menu directly:


Hi Vasiliy,

I'm using the Calypso project style – attached is the export from the Code Style menu, together with the code file example.php. 




Thanks for sharing both test file and code style config, I have managed to reproduce the behaviour on my side, it was a "Wrapping and Braces > Binary Expressions" section that I was missing on defaults.

However, while playing around with different options, I was not able to achieve the formatting style that you need, sorry. I will try some more but for now, all I may suggest is to use the "@formatter:off" option to disable the formatting of specific areas of code:


Hi Vasiliy,

I should maybe create a feature request for the desired behaviour. Many thanks for taking a look!



Please sign in to leave a comment.