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.
This task should improved the formatting and indentation in the PHP Editor. Please, paste there a samples, where the formatting or indentation don't work as you expect. Every case should contain a code before and after formatting and indentation.
One of the major (yet not easy to fix) problems I got with NetBeans is, that the current version lacks support for PEAR-style formatting. NetBeans allows either line-breaks: a) before and after all curly braces b) just after opening curly braces - but not a mixture. So it won't fit with either one - with weird result. Example: If you tell NetBeans to stick with formatting style "b" (as described above) foreach ($a as $b) <ENTER> | <- expect cursor to go here | <- but actually it goes there Actually it thinks, there was a curly brace in the line above. Well: it wasn't. Same problem with classes, when adding a new property by clicking the light-bulb to the left of your code: class foo | <- new member is created here { | <- expected it here So NetBeans relies too much on this setting. This is why I feel that most of the formatting problems I came across during many months of working with it are not bugs, but missing features. Other IDEs work in another way. They just check for curly braces and add +1 to the indentation depth if one is opened and -1 if one is closed. Thus: indentation is always right, no matter how the code is formatted. In a long-term I would like to see a way to tell NetBeans how *my* coding-standard should look like by giving an example. Or at least, I would like to be able to select the famous PEAR coding-standard, which is actually not possible. Since *our* coding-standard is not supported, I currently never use the built-in formatting-feature in NetBeans IDE. Instead I put it to a setting that is least annoying to us.
My main complains can be found in issue #173937, it's about indentation: --- 1 --- want to have: $checks[] = new G_Check("PHP version", version_compare(PHP_VERSION, MIN_PHP_VERSION, ">="),| // ENTER here "The minimum version of PHP is ".MIN_PHP_VERSION); but get: $checks[] = new G_Check("PHP version", version_compare(PHP_VERSION, MIN_PHP_VERSION, ">="), "The minimum version of PHP is ".MIN_PHP_VERSION); --- 2 --- function test() { do { echo "test"; } while ($condition); // press ENTER here | // you will get here } --- 3 --- <?php $arr = array(new ArrayIterator(array()), new ArrayObject(array()));| // ENTER here ?> --- 4 --- if ($a == 10 | // ENTER here, I want to type "&& $b == 20"
I don't know if you remember all the bugs I have complaint about at webexpo. 1) Duplicate line by shortucut ctrl + shift + arrow down does not work on last line. 2) When pressing tab on template (if, for, ...) it will not jump to the last ${cursor}. 3) It is impossible to create template with shortcut containg other character then letter.
To HonzaMarek: ad 1. - The bug is already in this database ( issue #173827 ). I have talked about this issue with editor guy and they promised to fix it. ad 2. - I have talked about this with Tomas ( he improved the behavior of the template recently). See this blog: http://blogs.sun.com/netbeansphp/entry/php_templates_improved . So it can be fixed. Tomas, could you please comment this. ad 3. - I also talk about this issue with the editor guys. As a result I entered new issue for this and they will try to fix it. They already have a solution for this, but no time to implement it. (issue #174903)
another point of endless discussions in PHP formatting is the difference of a space between the end of decision structures and the first ( or not, for example: if($foo) vs. if ($foo) Which would be nice to be supported in one or the other way.
Another issuse is: some source $a = $b +1; } |/** // cursor at the pipe char, then press enter * a comment Result: some source $a = $b +1; } /** * | // cursor at the pipe char * a comment But, I think, it's better to get a new line between } and /**
Also I have a problem with code completion (ctrl + space). class Something implements ArrayAccess { public function method() { /* @var $var OtherClass */ $var = $this["key"]; $var-> // it's offering methods for class Something } // ... }
To honzamarek: > ad 2. - I have talked about this with Tomas ( he improved the behavior of the template recently). See this blog: > http://blogs.sun.com/netbeansphp/entry/php_templates_improved . So it can be fixed. Tomas, could you please > comment this. I don't know the particular use case so please file a new issue (editor/options) with _exact_ steps to reproduce. Thanks.
To honzamarek: > Also I have a problem with code completion (ctrl + space). This issue is not about code completion. File a new issue, please. Thanks.
BEFORE: try{ ; }catch (Exception $e) { ; } AFTER it even has syntax error: try { ; }catch (Exception $e { ; }
Code after formatting: <?php class Demo { public $var = array( 'a', 'b', 'c' => array ( 'd', 'f', )); } How it should be: <?php class Demo { public $var = array( 'a', 'b', 'c' => array ( 'd', 'f', ) ); }
to ingoreinhart: the issue that you mentioned is entered as issue #174891, which I fixed yesterday.
It removes the indentation for these comments: //Gather Patient Data //Sylvia Suarez if(Users::InGroupCheck('Billing_FO_OPT_EVALS') || 1){ require_once 'superbills_pride_code.php'; $aBillTemp['EVAL'] = Superbills_CreateArray('EVAL', $sDate); $aBillTemp['OPT'] = Superbills_CreateArray('OPT', $sDate); } It should be like: //Gather Patient Data //Sylvia Suarez if(Users::InGroupCheck('Billing_FO_OPT_EVALS') || 1){ require_once 'superbills_pride_code.php'; $aBillTemp['EVAL'] = Superbills_CreateArray('EVAL', $sDate); $aBillTemp['OPT'] = Superbills_CreateArray('OPT', $sDate); }
To laurin1: I think the behavior is right now. It formats the inline comments if don't start on the first column. If you will do a space before // then they will be formatted correctly. The reason is a functionality, which comments out a line or selection (CTRL + / shortcut). For example you don't want to move this comments: if(Users::InGroupCheck('Billing_FO_OPT_EVALS') || 1){ require_once 'superbills_pride_code.php'; // $aBillTemp['EVAL'] = Superbills_CreateArray('EVAL', $sDate);// // $aBillTemp['OPT'] = Superbills_CreateArray('OPT', $sDate); }
abstract class PHPClass { public function method($a = 2, $b = null); } class ClassName extends PHPClass { // this is generated by 'generate method' feature and I don't like spaces after parameters public function method($a=2 , $b=null ) { parent::method($a, $b); } }
spaces for honzamarek: have a fix, will be applied tommorow
To Radek: > have a fix, will be applied tommorow Also, add spaces before and after "=" character, thanks.
My formatting option 'Braces Placement' is configured to 'New Line'. When I'm typing 'if' or 'for' statements without templates and hit <Enter> to break line, cursor stays on position to enter only one instruction, e.g.: if (true) | If I type a brace and hit <Enter> to start 'if', braces stays on wrong position, e.g.: if (true) { | } Pressing Alt+Shift-F to autoformat, that 'if' goes to right position, e.g: if (true) { | }
code: try { if($foo== 'bar'){ }else{ } }catch(InvalidArgumentException $e) { } is formatted: try { if($foo== 'bar') { }else { } }catch(InvalidArgumentException $ ) { } (variable $e is missing -> syntax error)
I cannot reproduce the last comment, stating that after formatting of try - catch there is a variable missing. A unit test has been created for this. @tombart: what version of netbeans are you using? thanks.
Hi, I'm glad this is brought up, for this is a huge problem for me that my IDE tries to tell me how my code should be indented. Sure, it's nice if it works exactly as you code, but I think theres too many coding styles to handle this. Would it be too much of a problem to just add an option to do simple indentation in the options menu. By simple indentation I mean that it should only remember what indentation level you're on, and continue on that.
Comment Newline Completion -------------------------- /*| type Enter here will result in /* * | */ which is nice when one is about to start a PHPDoc Comment or another standards compliant Comment, but not when your are about outcommenting some Code Block, or just want to put some Thoughts in a multiline Comment. If you do the latter much more than the first, this nice becomes annoying. Especially so: /* My Database - doesn't work| <--type Enter here - is great nevertheless */ becomes /* My Database - doesn't work * | - is great nevertheless */ which is definitely not helpful, I need to hit Backspaces on every line. Other example //my 1st task| <--type Enter here //my 2nd task will result in //my 1st task // | //my 2nd task which again might be nice in some Situations because it assumes a multiline Comment. But, me for Instance, never make multiline Comments in the // Style. Above Example was about completing Sort of a TODO List with Code, keeping the (singleline) Comments for Explanation. The helpful Thought becomes, well, isn't really helpful. Preferred Solution: - Make Comment Completion smarter, like being aware of Comment Style and having Stars already or not. - Make it controllable. Some options when to put a Star on the next Line, Intendation, which Type of Comments to complete. - Maybe as a first Measure: Make it completely optional. If its not helping me, at least let me turn it off (prefarrably for each Style optional).
I set that the braces to be "New Line Indented" and checked everything in "New Lines" in Alignments but this happens: if(true) { // code } // ENTER | <- expect cursor to go here | <- but actually it goes there the funny thing is that when I do code formatting the cursor moves to the right potion this bug is hunting me from the the beginning when these option where introduced