Changeset 1258

Show
Ignore:
Timestamp:
01/18/08 13:48:41 (10 months ago)
Author:
richi
Message:

enhancement #48: fixed bugs in stubSwitchDeclarationSniff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/org/stubbles/codeSniffer/stubbles/sniffs/ControlStructures/stubSwitchDeclarationSniff.php

    r1173 r1258  
    8888            } 
    8989 
    90            /* 
    91             * Stubbles (simplified if) 
    92             */ 
    93             $caseAhead = $phpcsFile->findNext(T_CASE, $nextCase+1, $switch['scope_closer']); 
    94             $nextBreak = $phpcsFile->findNext(T_BREAK, ($nextCase + 1), $caseAhead); 
    95             if ($nextBreak !== false) { 
     90            $nextBreak = $phpcsFile->findNext(T_BREAK, ($nextCase + 1), $switch['scope_closer']); 
     91            if ($nextBreak !== false && isset($tokens[$nextBreak]['scope_condition']) === true) { 
     92                // Only check this BREAK statement if it matches the current CASE 
     93                // statement. This stops the same break (used for multiple CASEs) being 
     94                // checked more than once. 
    9695 
    9796                /* 
     
    165164                    $phpcsFile->addError($error, $nextBreak); 
    166165                } 
     166 
    167167            } else { 
    168168                /* 
     
    177177 
    178178                $caseOrDefaultAhead    = $phpcsFile->findNext(array(T_CASE, T_DEFAULT), $nextCase+1, $switch['scope_closer']); 
    179                 if ($tokens[$caseOrDefaultAhead]['type'] !== T_CASE || $tokens[$caseOrDefaultAhead]['type'] !== T_DEFAULT) { 
    180                     // missing default handled below 
    181                     continue; 
    182                 } 
    183  
    184                 echo $tokens[$caseOrDefaultAhead]['code']; 
    185                 echo $tokens[$caseOrDefaultAhead]['type']; 
    186  
    187  
    188                 $requiredComment = "// break ommitted"; 
     179 
     180                // echo $tokens[$caseOrDefaultAhead]['code']; 
     181                // echo $tokens[$caseOrDefaultAhead]['type']; 
     182 
     183                $requiredComment = "// break omitted"; 
    189184                $next = array( 
    190185                            'return'  => null,