Skip to content

Commit b31b9b2

Browse files
committed
PSR2/SwitchDeclaration: minor efficiency tweak
1 parent ec015a8 commit b31b9b2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,15 @@ private function findNestedTerminator($phpcsFile, $stackPtr, $end)
343343
// We found the last statement of the CASE. Now we want to
344344
// check whether it is a terminating one.
345345
$terminators = [
346-
T_RETURN,
347-
T_BREAK,
348-
T_CONTINUE,
349-
T_THROW,
350-
T_EXIT,
346+
T_RETURN => T_RETURN,
347+
T_BREAK => T_BREAK,
348+
T_CONTINUE => T_CONTINUE,
349+
T_THROW => T_THROW,
350+
T_EXIT => T_EXIT,
351351
];
352352

353353
$terminator = $phpcsFile->findStartOfStatement(($lastToken - 1));
354-
if (in_array($tokens[$terminator]['code'], $terminators, true) === true) {
354+
if (isset($terminators[$tokens[$terminator]['code']]) === true) {
355355
return $terminator;
356356
}
357357
}//end if

0 commit comments

Comments
 (0)