Netbeans code format braces in PHP single line statements

寵の児 提交于 2019-12-10 18:17:15

问题


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?


回答1:


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




回答2:


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!




回答3:


Ok so it isn't possible I guess.




回答4:


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




回答5:


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".



来源:https://stackoverflow.com/questions/13801657/netbeans-code-format-braces-in-php-single-line-statements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!