From:  gsherwood@squiz.net
Date:  16 Dec 2014 10:02:31 Hong Kong Time
Newsgroup:  news.php.net/php.pear.bugs
Subject:  

[PEAR-BUG] Bug #20196 [Ana->Csd]: 1.5.2 breaks scope_closer position

NNTP-Posting-Host:  null

Edit report at https://pear.php.net/bugs/bug.php?id=20196&edit=1

 ID:               20196
 Updated by:       gsherwood@squiz.net
 Reported By:      james dot titcumb at protected dot co dot uk
 Summary:          1.5.2 breaks scope_closer position
-Status:           Analyzed
+Status:           Closed
 Type:             Bug
 Package:          PHP_CodeSniffer
 Package Version:  1.5.2
 PHP Version:      5.4.22
 Assigned To:      squiz
 Roadmap Versions: 
 New Comment:

-Status: Analyzed
+Status: Closed
I've finally fixed the original issue here: 
https://github.com/squizlabs/PHP_CodeSniffer/commit/6568a825c7731410f73cc54ec57
9eb923e9b6ed2

I had to add a special case for this syntax for if/elseif/else/endif,
but the openers and 
closers are now correct.


Previous Comments:
------------------------------------------------------------------------

[2014-02-19 23:35:01] squiz

None of the changes I've made has re-broken anything for me. I haven't
been able 
to fix the original issue, which is why your original code is still
broken.

The only way to write your statement so that PHPCS can detect it
properly is like 
this:

if ($foo):
    if ($bar):
        $foo = 1;
    elseif ($baz):
        $foo = 2;
    endif;
endif;

Because there is no ambiguity with the endif line, PHPCS can properly
match then. 
This was not working originally when you report the bug either, but I
have fixed 
this specific case.

------------------------------------------------------------------------

[2014-02-14 09:48:28] asgrim

Hmm - it seems to have gone back to being broken now, I think perhaps
the ELSE problem was masking it.

The scope opener (the first "if") is still picking up the "elseif" as
it's scope closer.

The sniff is basically the PEAR.WhiteSpace.ScopeClosingBrace.Indent
sniff, but modified slightly to use tabs instead of spaces. So I thought
I'd change the code snippet I provided to spaces: