Code Style: function and for parameters formatting on multiple lines

I went into Preferences (Mac) > Editor > Code Style > PHP, set Scheme to Project, then "Set from" to Predefined Style > PSR-1/PSR-2, but it pushed for loop and function parameters to their own lines... and I'm not seeing how to fix this.

Notice `function bar` definition in the screenshot below:

5 comments
Comment actions Permalink

Basically, I tried to "Set from" PSR-1/PSR-2 and I have a different bunch of settings in PhpStorm 2018.3.3

What version do you have installed?

0
Comment actions Permalink

That's what I did... if I select PSR-1/PSR-2 again, it separates out all params on their own lines:

I'm using version 2018.3.2, and haven't gotten the update prompt. Are you in Beta or something?

Can you try again and paste a screenshot of your settings like I did? Also please state your operating system.

0
Comment actions Permalink

Sure, I can. Please check the screenshot.

It is a fresh new project with code style set from PSR-1/PSR-2. I am using PhpStorm 2018.3.3 (released recently, received an update via Toolbox) installed on Windows 10.

0
Comment actions Permalink

Thank you Yur; it looks like yours is doing the same thing - notice your `function bar` on the right example has $x, $y, and int $z on their own lines... I'm trying to avoid this.

I notice in Function Declaration Parameters, 3 checkboxes are checked (after selecting PSR-1/PSR-2) that are causing the function/for parentheses to show on different lines; if I uncheck them, the parentheses do not show on their own lines, but the parameters do... I'm not seeing the setting to fix this.

In Laravel and PHP's code (and in PSR examples), parameters show on the same line. I'm not understanding why PHPStorm's PSR-1/PSR-2 setting is separating the parentheses and the parameters on their own lines, it appears to not be compliant.

Can someone explain this? It's looking like I'll have to manually configure this for PSR or Laravel unless someone already has a configuration they can export.

Here's my settings when I set them again to PSR-1/PSR-2:

0
Comment actions Permalink

In Laravel and PHP's code (and in PSR examples), parameters show on the same line. I'm not understanding why PHPStorm's PSR-1/PSR-2 setting is separating the parentheses and the parameters on their own lines, it appears to not be compliant.

Please note that chopping down is only happening when the line exceeds the guide, which is 120 characters in PSR-2.

When the line exceeds it, the only way to obey the standard is to chop the parameters.

What you see in the preview pane, is only a demonstration of this situation (please note that the guide is much shorter there), and should not apply to real code unless the code violates the standard.

Or, maybe there are code samples when a code that is formatted correctly being chopped when it does not exceed the guide?

0

Please sign in to leave a comment.