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 187192 - "Alternative syntax for control structures" in PHP are indented incorrectly
Summary: "Alternative syntax for control structures" in PHP are indented incorrectly
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 09:16 UTC by ozanhazer
Modified: 2010-10-26 22:58 UTC (History)
1 user (show)

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 ozanhazer 2010-06-04 09:16:56 UTC
"Alternative syntax for control structures" is commonly used in php based
template systems. They are much more readable than brackets when used inside
HTML.

Explained in:
http://php.net/manual/en/control-structures.alternative-syntax.php

When we do a Source/Format, the indentation is incorrect. I think the php tags should be indented to the wrapping HTML tag...

----------------------
What it should be like:
----------------------
<? if($enstitu['kod'] != 'EENS'):?>

<div class="CINT haric">

    <? if($enstitu['kod'] != 'MFBE'):?>

    <h2>Financial Support <span class="turkce">Finansal Destek </span></h2>

    <? else:?>

    <h2>Financial Support <span class="turkce">Finansal Destek </span></h2>

    <?
    $vals = array('I want Departmental Scholarship (Monthly scholarship, tuition waiver, accomodation)',
            'I will receive TÜBİTAK scholarship, I want tuition waiver and accomodation',
            'I want tuition waiver only',
            'I do not want any financial support'
    );

    $valsTr = array('Bölüm bursu istiyorum (Aylık burs, harç ücreti muafiyeti, yurt)',
            'TÜBİTAK bursu alacağım, sadece harç ücreti muafiyeti ve yurt istiyorum',
            'Sadece harç muafiyeti istiyorum',
            'Herhangi bir finansal destek istemiyorum'
    );
    ?>
    <table>
        <? foreach($vals as $key => $val):?>
        <tr valign="top">
            <td>
                <input type="radio" name="data[burs_istek_tur]" value="<?=$val?>">
            </td>
            <td>
                <strong><?=$val?></strong>
                <div class="note">
                    <?=$valsTr[$key]?>
                </div>
            </td>
        </tr>
        <? endforeach?>
    </table>

    <? endif?>

</div>

<? endif?>


----------------------
What Source/Format results:
----------------------

<? if($enstitu['kod'] != 'EENS'): ?>
    
    <div class="CINT haric">    
    
    <? if($enstitu['kod'] != 'MFBE'): ?>
    
        <h2>Financial Support <span class="turkce">Finansal Destek </span></h2>    
    
    <? else: ?>
        
            <h2>Financial Support <span class="turkce">Finansal Destek </span></h2>        
        
    <?
            $vals = array('I want Departmental Scholarship (Monthly scholarship, tuition waiver, accomodation)',
                'I will receive TÜBİTAK scholarship, I want tuition waiver and accomodation',
                'I want tuition waiver only',
                'I do not want any financial support'
            );

            $valsTr = array('Bölüm bursu istiyorum (Aylık burs, harç ücreti muafiyeti, yurt)',
                'TÜBİTAK bursu alacağım, sadece harç ücreti muafiyeti ve yurt istiyorum',
                'Sadece harç muafiyeti istiyorum',
                'Herhangi bir finansal destek istemiyorum'
            );

    ?>
            <table>        
<? foreach($vals as $key => $val): ?>
                <tr valign="top">        
                    <td>        
                <input type="radio" name="data[burs_istek_tur]" value="<?=$val ?>">
                </td>        
                <td>        
                    <strong><?=$val ?></strong>
                <div class="note">        
                            <?=$valsTr[$key] ?>
            </div>    
            </td>    
            </tr>    
<? endforeach ?>
            </table>        
        
<? endif ?>
            
            </div>            
            
<? endif ?>
Comment 1 bobw 2010-07-16 00:25:45 UTC
The alternative syntax should definitely be supported, but don't forget that it's not just for HTML files: you can use it in pure PHP files, too. In the latter case, the endxxx token should pretty much be handled like }, and balancing should work between it and the :.
Comment 2 Petr Pisl 2010-10-25 15:17:53 UTC
Now it should be ok. I have rewrite the part of formatter and now the formatter reflects the alternative syntax. You can check it with a development build. Let me know, whether now it works as you expect.
Comment 3 bobw 2010-10-26 22:58:09 UTC
Two things I notice:

1) After typing "switch (condition):" and hitting return, NB auto-inserts the endswitch, but it doesn't automatically indent the line between them as it does with the other control structurs.

2) This may be outside the scope of your change, but it would be very helpful if NT could balance-highlight the colon and endxxx, similar to what it does with { and }.