Skip to content

Commit 1e6555a

Browse files
committed
Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition
1 parent 7f61ecb commit 1e6555a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CodeSniffer/Tokenizers/PHP.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,14 @@ public function tokenizeString($string, $eolChar='\n')
446446
&& $tokens[($stackPtr + 1)] === ':'
447447
&& $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
448448
) {
449+
$stopTokens = array(
450+
T_CASE,
451+
T_SEMICOLON,
452+
T_OPEN_CURLY_BRACKET,
453+
);
454+
449455
for ($x = ($newStackPtr - 2); $x > 0; $x--) {
450-
if (in_array($finalTokens[$x]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
456+
if (in_array($finalTokens[$x]['code'], $stopTokens) === true) {
451457
break;
452458
}
453459
}

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
6161
- Squiz CSS sniffs no longer generate errors for IE filters
6262
- Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line
6363
- The PSR2 standard no longer throws errors for additional spacing after a type hint
64+
- Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition
6465
- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong
6566
-- Adds new error message for single-line arrays that end with a comma
6667
- Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses

0 commit comments

Comments
 (0)