Skip to content

Commit

Permalink
PSR2/SwitchDeclaration: minor efficiency tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl authored and gsherwood committed May 27, 2021
1 parent 8c9feda commit 263d8e9
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -343,15 +343,15 @@ private function findNestedTerminator($phpcsFile, $stackPtr, $end)
// We found the last statement of the CASE. Now we want to
// check whether it is a terminating one.
$terminators = [
T_RETURN,
T_BREAK,
T_CONTINUE,
T_THROW,
T_EXIT,
T_RETURN => T_RETURN,
T_BREAK => T_BREAK,
T_CONTINUE => T_CONTINUE,
T_THROW => T_THROW,
T_EXIT => T_EXIT,
];

$terminator = $phpcsFile->findStartOfStatement(($lastToken - 1));
if (in_array($tokens[$terminator]['code'], $terminators, true) === true) {
if (isset($terminators[$tokens[$terminator]['code']]) === true) {
return $terminator;
}
}//end if
Expand Down

0 comments on commit 263d8e9

Please sign in to comment.