function UnusedVariableSniff::isReference
1 call to UnusedVariableSniff::isReference()
- 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 604
Class
Namespace
SlevomatCodingStandard\Sniffs\VariablesCode
private function isReference(File $phpcsFile, int $scopeOwnerPointer, int $variablePointer) : bool {
$tokens = $phpcsFile->getTokens();
$scopeOpenerPointer = $tokens[$scopeOwnerPointer]['code'] === T_OPEN_TAG ? $scopeOwnerPointer : $tokens[$scopeOwnerPointer]['scope_opener'];
for ($i = $scopeOpenerPointer + 1; $i < $variablePointer; $i++) {
if ($tokens[$i]['code'] !== T_VARIABLE) {
continue;
}
if ($tokens[$i]['content'] !== $tokens[$variablePointer]['content']) {
continue;
}
$assignmentPointer = TokenHelper::findNextEffective($phpcsFile, $i + 1);
if ($tokens[$assignmentPointer]['code'] !== T_EQUAL) {
continue;
}
$referencePointer = TokenHelper::findNextEffective($phpcsFile, $assignmentPointer + 1);
if ($tokens[$referencePointer]['code'] === T_BITWISE_AND) {
return true;
}
}
return false;
}