Formatting - Braces

Based on the comments under this post the options for placing braces were changed. So this post is not relevant anymore and new information you can find here.

When you select PHP language in the formatting setting then in Category combo box you can select category Braces. The panel for this category contains only one combo box, where you can define the position of braces. There are three values -  Same Line, New Line and Preserve Existing. The default value is Same Line. See the picture.

 I'm not sure whether this one option is sufficient. Does someone have a requirement to offer more options for the braces? For example the Java formatting has options that allow to set different behavior for class declaration, methods declaration and other cases. Also it allows to set that  braces are indented on the new line.

Comments:

That is already cool!

As about options, would it be possible to have fourth option called 'PEAR Standard' (ect.) and achieve formatting like this:
http://pear.php.net/manual/en/standards.funcdef.php

So it is like new line for classes and functions, and same line for control structures.

Posted by e.s.t on February 05, 2010 at 10:49 AM CET #

To e.s.t: thanks for the link. From this is clear that I will have to make more options for this category.

Posted by Petr Pisl on February 05, 2010 at 11:03 AM CET #

Another link for you
http://framework.zend.com/manual/en/coding-standard.coding-style.html

It's largely based on the PEAR standard

Posted by Maghiel Dijksman on February 05, 2010 at 12:07 PM CET #

Great feature.
+1 for pear standard (new line for functions and classes and same line for other blocks)

Posted by matera.ttp on February 05, 2010 at 12:12 PM CET #

+1 for Zend (and other standards as well).

Certainly, having the same options that Java code formatting provides would be ideal. :)

Posted by Joel Simpson on February 05, 2010 at 12:30 PM CET #

I see big problem with use options new line. Classes and function are ok, but if, else, switch, try are in some line better.
You can add options as in spaces for different statements can use different braces.

+1 for Zend

Posted by Ladislav Prskavec on February 05, 2010 at 12:47 PM CET #

Hello all

Great feature !
I think it's important for the PHP industrialisation that you had PEAR and Zend coding standards.
I don't really know NetBeans but I'm working on it... This could be really awesome to be abble to couple the selected coding standards with PHP_CodeSniffer auto checking while coding. What do you think

Hope my frenchy english is clear enough

Posted by ladenise on February 05, 2010 at 03:19 PM CET #

Nice feature!
It would be nice to include options for class declarations and method declarations/calls, too. Would adding options for spaces between class/method names and braces be possible as well?

Posted by Martin Vrkljan on February 06, 2010 at 02:27 AM CET #

These options are satisfying for me!

On a related note I'd LOVE to see support for endif style control structures in netbeans. I find it much more readable than braces and it seems like it would be simple enough to make it work like HTML tag prediction, offering the closing statement after the opener is typed and highlighting the matching keyword when the cursor is in it's partner (ie highlight foreach when endforeach is clicked)

thanks and good luck with 6.9!

Posted by Jeremy Clarke on February 06, 2010 at 11:48 AM CET #

I agree with Jeremy Clarke,
by example in views it's quite common to use that structure.

Posted by Maghiel Dijksman on February 06, 2010 at 05:30 PM CET #

Very impressed so far with the new formatting features. Just a few things that I've noticed...

When formatting an interface function e.g,

function test();

The source formatting becomes...

function test()

;

Not sure why this is? Also, else/elseif statements don't get moved up a line if I specify other braces to be on the same line. So every time I do formatting, I need to go through and look for else statements and change from...

}
else {

to } else {

Also try formatting an empty class definition, for some reason the formatting removes the first brace of the class body and the ? in the ending php tag of the file.

Thanks very much, and if I've posted this in the wrong place, please let me know.

Drew

Posted by Andrew Higginson on March 03, 2010 at 05:04 AM CET #

Probably worth mentioning that my above comment was in relation to the new PHP formatting options.

Cheers,
Drew

Posted by Andrew Higginson on March 04, 2010 at 04:13 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today