Question

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?

Was it helpful?

Solution 3

Ok so it isn't possible I guess.

OTHER TIPS

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

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!

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

enter image description here

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top