function VariableAnalysisSniff::isNextThingAnAssign in Coder 8.2
Checks if the next token is an assignment.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile:
int $stackPtr:
Return value
bool
4 calls to VariableAnalysisSniff::isNextThingAnAssign()
- VariableAnalysisSniff::checkForAssignment in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Checks if the variable is being assigned to.
- VariableAnalysisSniff::checkForFunctionPrototype in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Checks the function prototype.
- VariableAnalysisSniff::checkForListAssignment in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Check if this is a list language construct assignment.
- VariableAnalysisSniff::checkForStaticDeclaration in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Check is this is a static variable declaration.
File
- coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php, line 1023
Class
- VariableAnalysisSniff
- Checks the for undefined function variables.
Namespace
DrupalPractice\Sniffs\CodeAnalysisCode
function isNextThingAnAssign(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile
->getTokens();
// Is the next non-whitespace an assignment?
$nextPtr = $phpcsFile
->findNext(T_WHITESPACE, $stackPtr + 1, null, true, null, true);
if ($nextPtr !== false) {
if ($tokens[$nextPtr]['code'] === T_EQUAL) {
return $nextPtr;
}
// Special handling for initializing arrays on the fly, which is
// also an assignment.
if ($tokens[$nextPtr]['code'] === T_OPEN_SQUARE_BRACKET) {
return $this
->isNextThingAnAssign($phpcsFile, $tokens[$nextPtr]['bracket_closer']);
}
}
return false;
}