function AssignmentInConditionSniff::process
Same name in this branch
- 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff::process()
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $conditionStartPointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ AssignmentInConditionSniff.php, line 41
Class
Namespace
SlevomatCodingStandard\Sniffs\ControlStructuresCode
public function process(File $phpcsFile, $conditionStartPointer) : void {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$conditionStartPointer];
if ($token['code'] === T_DO) {
$whilePointer = TokenHelper::findNext($phpcsFile, T_WHILE, $token['scope_closer'] + 1);
$whileToken = $tokens[$whilePointer];
$parenthesisOpener = $whileToken['parenthesis_opener'];
$parenthesisCloser = $whileToken['parenthesis_closer'];
$type = 'do-while';
}
else {
$parenthesisOpener = $token['parenthesis_opener'];
$parenthesisCloser = $token['parenthesis_closer'];
$type = $token['code'] === T_IF ? 'if' : 'elseif';
}
if ($parenthesisOpener === null || $parenthesisCloser === null) {
return;
}
$this->processCondition($phpcsFile, $parenthesisOpener, $parenthesisCloser, $type);
}