4

Intro

Im developing PHP in NetBeans IDE 7.2 (Build 201207171143) and I love the formatting to clean up my code in my custom format.

At the moment I work in a group with colleagues. Some of my colleagues are used to write single line statement without braces (I think this is bad practice).

Examples

What my colleagues do:

<?php

     if($stackoverflow == 'Cool')
           echo 'Stack Overflow is Cool!';

?>

What I want when I format the code.

<?php

     if($stackoverflow == 'Cool') {
           echo 'Stack Overflow is Cool!';
     }

?>

Question

So what I am looking for is the setting to achieve this. I can find every other setting to have nice braces.

Tools -> Options -> Editor -> Formatting -> PHP

WhatHaveITried

I have found this but I think this isn't the way for what I want to achieve since he talks about macros.

Could someone help me with this?

Community
  • 1
  • 1
Ron van der Heijden
  • 13,198
  • 7
  • 52
  • 79

5 Answers5

2

I am not sure if u have find the solution or not

Tools -> Options -> Editor -> Formatting
Language: PHP
Category: Braces

Select "same line" for all

Michael Law
  • 149
  • 1
  • 1
  • 11
0

Agree on a shared coding style! Don't rely on your editor to format and unformat code for you.

As for this example, I would argue that using brackets is better since it's less error prone - but this is something you have to agree upon with your collegues!

Halcyon
  • 54,624
  • 10
  • 83
  • 122
  • What if they also use netbeans with there own custom formatting. Then it doesn't matter anymore. This is only for reading throught the code and doesn't affect the results. All I'm asking for is how to achieve this. – Ron van der Heijden Dec 10 '12 at 14:08
-1

Ok so it isn't possible I guess.

Ron van der Heijden
  • 13,198
  • 7
  • 52
  • 79
-1

It is possible to format braces in PHP.
This is an example:

enter image description here

Tuyen Nguyen
  • 4,159
  • 7
  • 45
  • 76
-1

I finally found the answer to this. It is found under Options -> Editor -> Formatting -> select PHP under the language drop down -> select "Wrapping" category -> scroll down to see "If Statement" and select "Never".

Netbeans screenshot

chrisbjr
  • 628
  • 4
  • 10