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.
Further to Bug 216088 <?php /* test 1 */ if (TRUE) { $a = 1; } else { $a = 2; } /* test 2 */ if (TRUE) $a = 1; else $a = 2; /* test 3 */ if (TRUE) { $a = 1; } else $a = 2; /* test 4 */ if (TRUE) $a = 1; else { $a = 2; } /* test 5 */ if (TRUE) { ; } else { ; } /* test 6 */ if (TRUE) ; else ; /* test 7 */ if (TRUE) { ; } else ; /* test 8 */ if (TRUE) ; else { ; } ?> Observations: Curly? Empty? Fold? At Comment ======= ======= ======= ========== ===================== Yes No Yes if/else Expected Yes Yes Yes if/else Expected No No Yes statement Should be at if/else No Yes No N/A Should be at if/else Where: if/else = if or else as appropriate empty = ';' Also single line /* */ comments have a fold option, but should they?
> Also single line /* */ comments have a fold option, but should they? Yes. Because their type is multiline...just written in one line. It's ok. It's nonsense to handle that case separately. And to folding of single line conditional statements? We decided to NOT fold empty statements (which are not in burly blocks) according to changes in folding infrastructure, so they will not be folded. The question is, if we should fold non-empty single line statements? For now we do that. Everything works as inteded (it's not a defect), so we can track this issue as an enhancement to change the common behavior. We will see what will be the feedback of users in beta and 7.4 and can change it for next release.
My 2c.. > And to folding of single line conditional statements? We decided to NOT fold > empty statements (which are not in burly blocks) according to changes in > folding infrastructure, so they will not be folded. There is resistance to curly braces (PCS, FIG etc) for single line statements, but it is valid php, so I question the ide treating curly brace code differently to that without. Adds yet another layer of inconsistency, as the test code demonstrates. > The question is, if we should fold non-empty single line statements? For now we > do that. The question is not whether they should be able to be folded (agree they should), but rather the manner of their folding. IMHO the fold should always be applied at the conditional statement and fold all content, not at the content statement. Currently .. If curly braces, the fold includes the conditional, the statement and the curly braces - condensing three lines into one. If no curly braces just the statement line is folded, achieving no condensation and an obvious inconsistency. This simplicity of logic also applies to empty statements. In terms of code structure an empty statement (;) is surely no different to a non-empty one and should be treated exactly the same?