function UnusedVariableSniff::isInheritedVariablePassedByReference
1 call to UnusedVariableSniff::isInheritedVariablePassedByReference()
- 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 577
Class
Namespace
SlevomatCodingStandard\Sniffs\VariablesCode
private function isInheritedVariablePassedByReference(File $phpcsFile, int $functionPointer, string $variableName) : bool {
$tokens = $phpcsFile->getTokens();
$usePointer = TokenHelper::findNextEffective($phpcsFile, $tokens[$functionPointer]['parenthesis_closer'] + 1);
if ($tokens[$usePointer]['code'] !== T_USE) {
return false;
}
$useParenthesisOpener = TokenHelper::findNextEffective($phpcsFile, $usePointer + 1);
for ($i = $useParenthesisOpener + 1; $i < $tokens[$useParenthesisOpener]['parenthesis_closer']; $i++) {
if ($tokens[$i]['code'] !== T_VARIABLE) {
continue;
}
if ($tokens[$i]['content'] !== $variableName) {
continue;
}
$pointerBeforeInheritedVariable = TokenHelper::findPreviousEffective($phpcsFile, $i - 1);
if ($tokens[$pointerBeforeInheritedVariable]['code'] === T_BITWISE_AND) {
return true;
}
}
return false;
}