0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, You are right. The "Brackets" option does not affect array initializer brackets. Also, The "Array initializer parentheses" option formats array initializer brackets too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.