function FunctionCallArgumentSpacingSniff::process
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token in the: stack passed in $tokens.
Return value
void
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Generic/ Sniffs/ Functions/ FunctionCallArgumentSpacingSniff.php, line 51
Class
Namespace
PHP_CodeSniffer\Standards\Generic\Sniffs\FunctionsCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
// Skip tokens that are the names of functions or classes
// within their definitions. For example:
// function myFunction...
// "myFunction" is T_STRING but we should skip because it is not a
// function or method *call*.
$functionName = $stackPtr;
$ignoreTokens = Tokens::$emptyTokens;
$ignoreTokens[] = T_BITWISE_AND;
$functionKeyword = $phpcsFile->findPrevious($ignoreTokens, $stackPtr - 1, null, true);
if ($tokens[$functionKeyword]['code'] === T_FUNCTION || $tokens[$functionKeyword]['code'] === T_CLASS) {
return;
}
if ($tokens[$stackPtr]['code'] === T_CLOSE_CURLY_BRACKET && isset($tokens[$stackPtr]['scope_condition']) === true) {
// Not a function call.
return;
}
// If the next non-whitespace token after the function or method call
// is not an opening parenthesis then it can't really be a *call*.
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, $functionName + 1, null, true);
if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
return;
}
if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
return;
}
$this->checkSpacing($phpcsFile, $stackPtr, $openBracket);
}