function SwitchDeclarationSniff::findNextCase
Find the next CASE or DEFAULT statement from a point in the file.
Note that nested switches are ignored.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position to start looking at.:
int $end The position to stop looking at.:
Return value
int|false
2 calls to SwitchDeclarationSniff::findNextCase()
- SwitchDeclarationSniff::findNestedTerminator in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ ControlStructures/ SwitchDeclarationSniff.php - Returns the position of the nested terminating statement.
- SwitchDeclarationSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ ControlStructures/ SwitchDeclarationSniff.php - Processes this test, when one of its tokens is encountered.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ ControlStructures/ SwitchDeclarationSniff.php, line 217
Class
Namespace
PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructuresCode
private function findNextCase($phpcsFile, $stackPtr, $end) {
$tokens = $phpcsFile->getTokens();
while (($stackPtr = $phpcsFile->findNext([
T_CASE,
T_DEFAULT,
T_SWITCH,
], $stackPtr, $end)) !== false) {
// Skip nested SWITCH statements; they are handled on their own.
if ($tokens[$stackPtr]['code'] === T_SWITCH) {
$stackPtr = $tokens[$stackPtr]['scope_closer'];
continue;
}
break;
}
return $stackPtr;
}