Codestyle, blank line after property declaration and before comments.

Hello, I usually group the methods in my classes with a set of 3 lines with comments, like this:

//---------------------------------------------------------------------//
// Setup //
//---------------------------------------------------------------------//

Question: In PhpStorm, how do I force a blank line between a set of private properties in a class and the first block of comments?

Before applying [Ctrl]+[Alt]+[L] I have it like this:

After pressing [Ctrl]+[Alt]+[L] I get this:

Question: How do I force the blank line to be there? I don't seem to find the option.

 

0
8 comments

Hi there,

What's your "Code Style | PHP | Blank Lines" settings are?

Settings from Default scheme do not remove such line; do not add either. So if you have such empty line there already it should be preserved.

0

Well... it might be a bug... Look:

If the comment has EXACTLY one line, then, as you say @Andriy, it does NOT add or remove lines.

Instead, if the comment has more than one line, it actually removes the blank line...

To reproduce, I created a blank file with a dummy class, with a property, a comment and a method.

In [1] you can see I leave exactly one blank line before and one after the comment.

I press [CTRL]+[ALT]+[L] and the code gets formatted, but doing nothing (as expected):

In [2] you can see no lines were added or removed. And in [3] you see the formatter expressing he did nothing.

Instead, if I just add another comment line, lilke in the following example, the behaviour is not as expected:

Here in [4] you can see there is exactly one blank line before and after, just as before. The very only difference is that I just have TWO comment lines instead of one.

[CTRL]+[ALT]+[L] and... oops!!! What's up?

In [5] you can see the top blank line line was actually removed by the formatter, and in [6] it cries out loud that 1 line was formatted.

So...

Q1) Why this happens? Feature or bug?

Q2) If it's a bug, what should I do to report it?

0

Those are my settings:

Happens also in the "tester" area. If I put 1 comment line, it is not "glued" to the property declaration and the blank-line is respected. If I put 2 or more comment lines, then the blank line is deleted. In both cases, the configuration remains exactly the same.

0

Please reset it to Default (e.g. create new one or whatnot) and try again -- it works just fine here -- those comments do not move (not getting glued to the field above them):

Maybe try with ALL not bundled by default plugins disabled (just in case if some of them interfere somehow).

Also check what idea.log (Help | Show Log in ...) may have to say

 

 

0
Avatar
Permanently deleted user

This error still exists for CSS and SCSS: Comment blocks loose their empty line above, when code is reformatted. Please fix or add an option in the CSS code styling options. Thank you!

0

@Robert Wildling 

Formatter implementation is different for each language. Your issue/expected behaviour has nothing to do with the original thread (PHP).

Please report your issue to WebStorm Issue Tracker (it's home for all JS/CSS/HTML tickets) ... but check for existing tickets...

1
Avatar
Permanently deleted user

 

@andriy Are you a IDEA developer?

0

Please sign in to leave a comment.