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.

Bug 124273 - [formatting] Support formatting across multiple disjoint php sections
Summary: [formatting] Support formatting across multiple disjoint php sections
Status: RESOLVED DUPLICATE of bug 175229
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Tomasz Slota
URL:
Keywords:
: 175425 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-19 16:00 UTC by Andrew Korostelev
Modified: 2009-10-27 16:33 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Korostelev 2007-12-19 16:00:58 UTC
if there is html code on the same line before open php tag '<?php', 
closing php tag '?>' indent will be zero.
It is not suitable for php user and is not consistent with html formatter behavior.

It seems that another condition necessary to reproduce issue is that related php code is spreaded into several php blocks.

The following php code is formatted by php formatter:

//-----start example-------
<body><?php
    if ($a == 1){
    ?>    
    <br/><?php                        
    $r =123;               
?><br/>
<?php
}
?>
</body>
//-----end example  -------

Problem:the following line indent is 0:
'?><br/>' 

Note: separate php block with line 'if ($a == 1){' is necessary for reproducing an issue.
Comment 1 Andrew Korostelev 2007-12-19 16:07:53 UTC
another problem in suggested example is that 
'$r =123;'
has the same indent as 
'if ($a == 1){'.

The same php formatter makes '$r =123;' indent 1 tab more if you will place '<?php' on the separate line.

Tomash, Should this be filed as separate issue?
Comment 2 Tomasz Slota 2008-01-14 15:40:03 UTC
It is probably the same problem (I will confirm it once the editor is usable again). Speaking short the core of the problem is that now there is no formatter for 
the top-level PHP language, only for the embedded sections 
Comment 3 Tomasz Slota 2008-04-09 09:24:38 UTC
Vito please evaluate if this issue is still valid in the current implementation
Comment 4 Vitezslav Stejskal 2008-04-09 14:13:37 UTC
Yes, this is still a problem. I assume the expected formatting is:

<body><?php
    if ($a == 1){
    ?>    
    <br/><?php                        
        $r =123;               
    ?><br/>
    <?php
    }
    ?>
</body>


Is that correct? Currently the formatter does not work with disjoint sections, which is causing this problem.
Comment 5 Jiri Prox 2008-04-25 13:09:27 UTC
The number of next version is already known -> moving from TM Dev to 6.5
Comment 6 Tomasz Slota 2008-06-02 14:10:15 UTC
Downgrading to P3
Comment 7 Filip Zamboj 2009-10-14 16:43:22 UTC
consider code like: 
<body>
    <?php if ($a == 1) { ?>    
    <br/>
        <?php  $r =123; ?>
    <br/>
        <?php } ?>
</body>

invoke formatting and you get: 
<body>
    <?php if ($a == 1) { 
    ?>    
    <br/>
    <?php  $r =123;
        ?>
    <br/>
    <?php 
} 
?>
</body> 

a. ?> tags were moved to next line, why? 
b. the last code <?php } ?> is formatted wrong 

the expected result here is: 
<body><?php if ($a == 1) { ?>    
                <br/>
                <?php $r =123; ?>
                <br/>
      <?php } ?>
</body>
However I don't really see how if should be handled .. but I suggested it above :). 

the example of original reporter is still formatted wrong. The result of his example is: 
<body><?php
    if ($a == 1) {
        ?>    
    <br/><?php                     
        $r =123;               
        ?><br/>
        <?php
    } // this is correct, see the first example in this comment. there is a difference for some reason. 
    ?> // this one is weird, why here, it looks like it is out of scope 
</body>


Product Version: NetBeans IDE Dev (Build 091014)
Java: 1.6.0_16; Java HotSpot(TM) 64-Bit Server VM 14.2-b01
Comment 8 Tomasz Slota 2009-10-20 16:34:41 UTC
I fixed the part with unwanted splitting of lines described by fzamboj:

http://hg.netbeans.org/web-main/rev/89c0e3932273
Comment 9 Filip Zamboj 2009-10-22 17:37:17 UTC
@tslota: 

I added few formatting unit tests to part that was supposed to be fixed. they are failing, though :(:(. Could you have a
look? I think tests are fine. 

You can find them in formatting/qa/14273_x.php where _x is number > 0 and < 4 ;).  
Comment 10 Quality Engineering 2009-10-23 10:08:09 UTC
Integrated into 'main-golden', will be available in build *200910230201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f512b5091bc7
User: Filip Zamboj <fzamboj@netbeans.org>
Log: #124273 unit tests added - more complex cases are still missing
Comment 11 Filip Zamboj 2009-10-26 14:45:40 UTC
*** Issue 175425 has been marked as a duplicate of this issue. ***
Comment 12 Tomasz Slota 2009-10-27 16:33:29 UTC
as pe agreement with Filip this issue will be merged with issue 175229

*** This issue has been marked as a duplicate of 175229 ***