This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When trying to adhere to PSR2 I have the following settings for Blank Lines: Before Class: 1, After Class Header: 0, Before Class End: 0, After Class 1. This should result in a class being formatted as: class Foo() { protected $fakeItem; } However what I get is: class Foo() { protected $fakeItem; } The extra blank lines cause the file to fail PSR2. It is as if the 0 is not recognized and therefore defaulting to 1. If I set it to 2 I correctly get 2 blank lines so I don;t think it is being overriden by something else.
Looking again I think this is due to After function being set as 1. Class End should override after function as you are setting it for the end of the class. If you set function end to 0 you won't get a space between multiple functions.
Perhaps, you have the following settings: - Before Fields: 1 - After Fields: 1 Please try changing them to 0. BTW, I don't think that it is P2. Thanks.
LOL Priority would depend on whether or not your code has to adhere to PSR2 I guess :) I have tried your suggestion but when formatting and there are no fields I still get a blank line added. I looked at the source code for the formatter and there seems to be some kind of exception to the rule which is causing this to happen. See below from TokenFormatter.java starting at line 617 in my version of the source: case WHITESPACE_AFTER_CLASS_LEFT_BRACE: indentRule = true; newLines = docOptions.blankLinesAfterClassHeader + 1 > newLines ? docOptions.blankLinesAfterClassHeader + 1 : newLines; countSpaces = indent; break; There is the bit that checks to see if the set option + 1 is greater than new lines and if it is then an extra line is added. When the class only has functions and no fields then this extra line is always inserted. When there are fields it is not. I think it should always insert the number of lines that the user has set if they are trying to adhere to PSR2.
(In reply to junichi11 from comment #2) > - Before Fields: 1 > - After Fields: 1 > > Please try changing them to 0. With this settings, it works for me without any problem. Thanks for reporting. Product Version: NetBeans IDE Dev (Build 20160817-5dcbb81aefbb) Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13 Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13 System: Linux version 4.4.0-34-generic running on amd64; UTF-8; cs_CZ (nb)