function UseDeclarationSniff::shouldIgnoreUse
Check if this use statement is part of the namespace block.
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
bool
1 call to UseDeclarationSniff::shouldIgnoreUse()
- UseDeclarationSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ Namespaces/ UseDeclarationSniff.php - Processes this test, when one of its tokens is encountered.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ PSR2/ Sniffs/ Namespaces/ UseDeclarationSniff.php, line 277
Class
Namespace
PHP_CodeSniffer\Standards\PSR2\Sniffs\NamespacesCode
private function shouldIgnoreUse($phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
// Ignore USE keywords inside closures and during live coding.
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
if ($next === false || $tokens[$next]['code'] === T_OPEN_PARENTHESIS) {
return true;
}
// Ignore USE keywords for traits.
if ($phpcsFile->hasCondition($stackPtr, [
T_CLASS,
T_TRAIT,
T_ENUM,
]) === true) {
return true;
}
return false;
}