Permalink
Browse files

Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break …

…statement indentation error
  • Loading branch information...
1 parent 07e9a42 commit c275359a3f4f9ebc09b8b7cfe69e79052ddf3ec6 @gsherwood gsherwood committed Apr 12, 2013
Showing with 4 additions and 2 deletions.
  1. +3 −2 CodeSniffer/File.php
  2. +1 −0 package.xml
View
@@ -1491,10 +1491,11 @@ private static function _recurseScopeMap(
// scope tokens. If an IF statement below this one has an opener but no
// keyword, the opener will be incorrectly assigned to this IF statement.
// E.g., if (1) 1; 1 ? (1 ? 1 : 1) : 1;
- if ($currType === T_IF && $opener === null && $tokens[$i]['code'] === T_SEMICOLON) {
+ if (($currType === T_IF || $currType === T_ELSE) && $opener === null && $tokens[$i]['code'] === T_SEMICOLON) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
+ $type = $tokens[$stackPtr]['type'];
echo str_repeat("\t", $depth);
- echo "=> Found semicolon before scope opener for $stackPtr (T_IF), bailing".PHP_EOL;
+ echo "=> Found semicolon before scope opener for $stackPtr ($type), bailing".PHP_EOL;
}
return $i;
View
@@ -28,6 +28,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<notes>
- Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable
-- Thanks to Maik Penz for the patch
+ - Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error
</notes>
<contents>
<dir name="/">

0 comments on commit c275359

Please sign in to comment.