function JumpStatementsSpacingSniff::isFirstInCaseOrDefault
1 call to JumpStatementsSpacingSniff::isFirstInCaseOrDefault()
- JumpStatementsSpacingSniff::getLinesCountBeforeFirst in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ JumpStatementsSpacingSniff.php
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ JumpStatementsSpacingSniff.php, line 241
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
private function isFirstInCaseOrDefault(File $phpcsFile, int $jumpStatementPointer) : bool {
$tokens = $phpcsFile->getTokens();
$previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $jumpStatementPointer - 1);
if ($tokens[$previousPointer]['code'] !== T_COLON) {
return false;
}
$firstPointerOnLine = TokenHelper::findFirstNonWhitespaceOnLine($phpcsFile, $previousPointer);
return in_array($tokens[$firstPointerOnLine]['code'], [
T_CASE,
T_DEFAULT,
], true);
}