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.
I'm using dev-build 201704120200. The following issue was introduced after code changes submitted to fix issue 206532. This changeset http://hg.netbeans.org/main-silver/rev/55a9fd535b01 introduced a hint when a Non-Abstract PHP function was found that didn't have a body. Part of the changeset is the method AddBodyFix.implement() that is called when the user chooses to automatically apply a fix for the hint. When certain formatting & indentation settings are selected, the auto-formatting feature doesn't seem to behave as intended. To replicate this behavior, go to menu "Tools / Options / Editor / Formatting". Set "PHP / Braces / Method declaration" to "New Line". Here are some test cases. Source code BEFORE applying the hint-fix: <?php class Test1 { private function test(); } class Test2 { private function test(); } class Test3 { private function test(); } class Test4 { private function test() ; } ?> Results AFTER applying the hint-fix: <?php class Test1 { private function test() { } } class Test2 { private function test() { } } class Test3 { private function test() { } } class Test4 { private function test() { } } ?> EXPECTED: <?php class Test1 { private function test() { } } class Test2 { private function test() { } } class Test3 { private function test() { } } class Test4 { private function test() { } } ?> Obviously applying the hint behaves differently depending on how many spaces are found before the head of the function and introduces the exact same number of spaces as the function head is indented. It appears to be unclear what exactly causes this behavior.
Thanks for reporting! I'll look at it later.
I think that the same result is expected. i.e. EXPECTED: <?php class Test1 { private function test() { } } class Test2 { private function test() { } } class Test3 { private function test() { } } class Test4 { private function test() { } }
You are absolutely right! Ideally, yes, all should be the same. However, that depends on what you apply the formatting to: do you apply it to the head of the function as well (thus changing the formatting of preexisting code), or only to the body that was inserted by applying the hint-fix. There is good arguments for both options. I personally would have it your way, but that's just my personal preference ;)
Fixed. http://hg.netbeans.org/web-main/rev/6613b6ada27e Thanks.
Integrated into 'main-silver', will be available in build *201704150002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/6613b6ada27e User: Junichi Yamamoto <junichi11@netbeans.org> Log: #270385 - Hint-Fix not properly formatted
Thanks a lot, Junichi!
I just tried the fix with the current Nightly Build 201704180002. Works perfectly well. Thanks! Great job.
You are welcome :)