function ForbiddenClassesSniff::process
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $tokenPointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ PHP/ ForbiddenClassesSniff.php, line 90
Class
Namespace
SlevomatCodingStandard\Sniffs\PHPCode
public function process(File $phpcsFile, $tokenPointer) : void {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$tokenPointer];
$nameTokens = array_merge(TokenHelper::getNameTokenCodes(), TokenHelper::$ineffectiveTokenCodes);
if ($token['code'] === T_IMPLEMENTS || $token['code'] === T_USE && UseStatementHelper::isTraitUse($phpcsFile, $tokenPointer)) {
$endTokenPointer = TokenHelper::findNext($phpcsFile, [
T_SEMICOLON,
T_OPEN_CURLY_BRACKET,
], $tokenPointer);
$references = $this->getAllReferences($phpcsFile, $tokenPointer, $endTokenPointer);
if ($token['code'] === T_IMPLEMENTS) {
$this->checkReferences($phpcsFile, $tokenPointer, $references, $this->forbiddenInterfaces);
}
else {
// Fixer does not work when traits contains aliases
$this->checkReferences($phpcsFile, $tokenPointer, $references, $this->forbiddenTraits, $tokens[$endTokenPointer]['code'] !== T_OPEN_CURLY_BRACKET);
}
}
elseif (in_array($token['code'], [
T_NEW,
T_EXTENDS,
], true)) {
$endTokenPointer = TokenHelper::findNextExcluding($phpcsFile, $nameTokens, $tokenPointer + 1);
$references = $this->getAllReferences($phpcsFile, $tokenPointer, $endTokenPointer);
$this->checkReferences($phpcsFile, $tokenPointer, $references, $token['code'] === T_NEW ? $this->forbiddenClasses : $this->forbiddenExtends);
}
elseif ($token['code'] === T_DOUBLE_COLON && !$this->isTraitsConflictResolutionToken($token)) {
$startTokenPointer = TokenHelper::findPreviousExcluding($phpcsFile, $nameTokens, $tokenPointer - 1);
$references = $this->getAllReferences($phpcsFile, $startTokenPointer, $tokenPointer);
$this->checkReferences($phpcsFile, $tokenPointer, $references, $this->forbiddenClasses);
}
}