function UnusedVariableSniff::isValueInForeachAndErrorIsIgnored
1 call to UnusedVariableSniff::isValueInForeachAndErrorIsIgnored()
- UnusedVariableSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Variables/ UnusedVariableSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Variables/ UnusedVariableSniff.php, line 516
Class
Namespace
SlevomatCodingStandard\Sniffs\VariablesCode
private function isValueInForeachAndErrorIsIgnored(File $phpcsFile, int $variablePointer) : bool {
$tokens = $phpcsFile->getTokens();
$parenthesisOwnerPointer = $this->findNestedParenthesisWithOwner($phpcsFile, $variablePointer);
$isInForeach = $parenthesisOwnerPointer !== null && $tokens[$parenthesisOwnerPointer]['code'] === T_FOREACH;
if (!$isInForeach) {
return false;
}
$pointerAfterVariable = TokenHelper::findNextEffective($phpcsFile, $variablePointer + 1);
if ($pointerAfterVariable !== null && $tokens[$pointerAfterVariable]['code'] === T_DOUBLE_ARROW) {
return false;
}
return $this->ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach;
}