function DisallowContinueWithoutIntegerOperandInSwitchSniff::process
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $continuePointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ DisallowContinueWithoutIntegerOperandInSwitchSniff.php, line 33
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
public function process(File $phpcsFile, $continuePointer) : void {
$tokens = $phpcsFile->getTokens();
$operandPointer = TokenHelper::findNextEffective($phpcsFile, $continuePointer + 1);
if ($tokens[$operandPointer]['code'] === T_LNUMBER) {
return;
}
$conditionTokenCode = current(array_reverse($tokens[$continuePointer]['conditions']));
if ($conditionTokenCode !== T_SWITCH) {
return;
}
$fix = $phpcsFile->addFixableError('Usage of "continue" without integer operand in "switch" is disallowed, use "break" instead.', $continuePointer, self::CODE_DISALLOWED_CONTINUE_WITHOUT_INTEGER_OPERAND_IN_SWITCH);
if (!$fix) {
return;
}
$phpcsFile->fixer
->beginChangeset();
$phpcsFile->fixer
->replaceToken($continuePointer, 'break');
$phpcsFile->fixer
->endChangeset();
}