PhpStorm “Reformat Code” breaks line at PHP () calls using newline

Let's say I have this line of PHP code:

if ($this->request->getModuleName() == 'abc' && $this->request->getControllerName() == 'test' && $this->request->getActionName() == 'test') {

I then use PhpStorms "Reformat Code" function to reformat the code, it becomes this:

if ($this->request && $this->request->getModuleName(
) == 'abc' && $this->request->getControllerName(
) == 'test' && $this->request->getActionName() == 'test'
) {

But why does it add the new line after a ( and before a )? Shouldn't it better break at &&? Like this, which is better readable:

if ($this->request && $this->request->getModuleName() == 'abc'
&& $this->request->getControllerName() == 'test'
&& $this->request->getActionName() == 'test') {

I cannot find the option in PhpStorms settings to fix this. The max line length is set to 120 chars.

Unfortunately there doesn't seem to be an option to change the code style to be like I'd expect it to be. There's the "wrapping" function for "functions" which allows to wrap after ( and before ) but it doesn't seem to be able to break at &&.

0
1 comment

Hi there,

Please share your code style settings. Either config file (ideally) or some screenshots at least.

If you use "Default" code style -- will it format it correctly?

0

Please sign in to leave a comment.