Hoytman
Hoytman

Reputation: 1812

PhpStorm Code Style 'Space - Within - Brackets' not functioning

I am working on a PHP Laravel project with a team that requires spaces within brackets like this:

 $t = $one[ 0 ];

I attempted to accomplish this by set the following requirement in the Code Style Preference:

enter image description here

The highlights show that spaces should be added within brackets as needed. However, after saving and restarting, I do not get this style applied, no matter how many time I press Ctrl+Alt+L.

Worse still, PhpStorm strips out the spaces that already exist within brackets, which causes a huge headache when I try to auto format existing code.

So this:

enter image description here

Is reformatted and becomes this:

enter image description here

I've set up other custom code style setting, and the other custom setting are getting applied.

Could someone offer some help with fixing this style problem?

Upvotes: 0

Views: 390

Answers (1)

LazyOne
LazyOne

Reputation: 165088

That option works just fine. It is for accessing individual array elements (e.g. $t = $one[ 0 ];).

But on your screenshots, where it does not work... it's array initializer (in other words, $var = array('aaa', 'bbb');)... and for that you need to use appropriate option -- "Array initializer parentheses" (which is just a bit below of what you have tried above).

enter image description here

Upvotes: 1

Related Questions