Processes this test, when one of its tokens is encountered.

@param File $phpcsFile The file being scanned.
@param int  $stackPtr  The position of the current token in the
stack passed in $tokens.

@return void
14156
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if ($tokens[$stackPtr]['code'] === T_COMMENT) {
            $this->processComment($phpcsFile, $stackPtr);
        } elseif ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) {
            $this->processDocBlock($phpcsFile, $stackPtr);
        }
    }
123203
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.0') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();
        $token  = $tokens[$stackPtr];
        // Skip function without body.
        if (isset($token['scope_opener']) === false) {
            return;
        }

        // Get all parameters from method signature.
        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
        if (empty($parameters) || \is_array($parameters) === false) {
            return;
        }

        $paramNames = array();
        foreach ($parameters as $param) {
            $paramNames[] = strtolower($param['name']);
        }

        if (\count($paramNames) !== \count(array_unique($paramNames))) {
            $phpcsFile->addError(
                'Functions can not have multiple parameters with the same name since PHP 7.0',
                $stackPtr,
                'Found'
            );
        }
    }
429238
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $ignore = array(
            \T_DOUBLE_COLON    => true,
            \T_OBJECT_OPERATOR => true,
            \T_FUNCTION        => true,
            \T_CLASS           => true,
            \T_CONST           => true,
            \T_USE             => true,
            \T_NS_SEPARATOR    => true,
        );

        $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
            // Not a call to a PHP function.
            return;
        }

        $function   = $tokens[$stackPtr]['content'];
        $functionLc = strtolower($function);

        if (isset($this->removedFunctions[$functionLc]) === false) {
            return;
        }

        $itemInfo = array(
            'name'   => $function,
            'nameLc' => $functionLc,
        );
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
    }
529843
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.0') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();
        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
            return;
        }

        $defaultToken = $stackPtr;
        $defaultCount = 0;
        $targetLevel  = $tokens[$stackPtr]['level'] + 1;
        while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(\T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
            // Same level or one below (= two default cases after each other).
            if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
                $defaultCount++;
            }
        }

        if ($defaultCount > 1) {
            $phpcsFile->addError(
                'Switch statements can not have multiple default blocks since PHP 7.0',
                $stackPtr,
                'Found'
            );
        }
    }
514866
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens     = $phpcsFile->getTokens();
        $modifyLeft = substr($tokens[($stackPtr - 1)]['content'], 0, 1) === '$'
            || $tokens[($stackPtr + 1)]['content'] === ';';

        if ($modifyLeft === true && $tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
            $error = 'There must not be a single space before an unary operator statement';
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'ExtraSpaceBefore');

            if ($fix === true) {
                $phpcsFile->fixer->beginChangeset();
                $phpcsFile->fixer->replaceToken(($stackPtr - 1), '');
                $phpcsFile->fixer->endChangeset();
            }
        }

        if ($modifyLeft === false && substr($tokens[($stackPtr + 1)]['content'], 0, 1) !== '$') {
            $error = 'A unary operator statement must not followed by a single space';
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'ExtraSpaceAfter');

            if ($fix === true) {
                $phpcsFile->fixer->beginChangeset();
                $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
                $phpcsFile->fixer->endChangeset();
            }
        }
    }
278862
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $ignore = array(
                   T_DOUBLE_COLON => true,
                   T_FUNCTION     => true,
                   T_CONST        => true,
                   T_PUBLIC       => true,
                   T_PRIVATE      => true,
                   T_PROTECTED    => true,
                   T_AS           => true,
                   T_NEW          => true,
                   T_INSTEADOF    => true,
                   T_NS_SEPARATOR => true,
                   T_IMPLEMENTS   => true,
                  );

        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);

        // If function call is directly preceded by a NS_SEPARATOR it points to the
        // global namespace, so we should still catch it.
        if ($tokens[$prevToken]['code'] === T_NS_SEPARATOR) {
            $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($prevToken - 1), null, true);
            if ($tokens[$prevToken]['code'] === T_STRING) {
                // Not in the global namespace.
                return;
            }
        }

        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
            // Not a call to a PHP function.
            return;
        }

        $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
        if (isset($ignore[$tokens[$nextToken]['code']]) === true) {
            // Not a call to a PHP function.
            return;
        }

        if ($tokens[$stackPtr]['code'] === T_STRING && $tokens[$nextToken]['code'] !== T_OPEN_PARENTHESIS) {
            // Not a call to a PHP function.
            return;
        }

        $function = strtolower($tokens[$stackPtr]['content']);
        $pattern  = null;

        if ($this->patternMatch === true) {
            $count   = 0;
            $pattern = preg_replace(
                $this->forbiddenFunctionNames,
                $this->forbiddenFunctionNames,
                $function,
                1,
                $count
            );

            if ($count === 0) {
                return;
            }

            // Remove the pattern delimiters and modifier.
            $pattern = substr($pattern, 1, -2);
        } else {
            if (in_array($function, $this->forbiddenFunctionNames) === false) {
                return;
            }
        }//end if

        $this->addError($phpcsFile, $stackPtr, $function, $pattern);

    }
403040
public function process(File $phpcsFile, $stackPtr) {
		$tokens = $phpcsFile->getTokens();
		$utils = \PHPCS_SecurityAudit\Sniffs\UtilsFactory::getInstance();

		if ($tokens[$stackPtr]['content'] == 'phpinfo') {
			$phpcsFile->addWarning('phpinfo() function detected', $stackPtr, 'WarnPhpinfo');
		}

	}
480700
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens    = $phpcsFile->getTokens();
        $namespace = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1));

        if ($namespace === false) {
            $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
            $data  = array($tokens[$stackPtr]['content']);
            $phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $data);
        }
    }
1255168
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
        if ($tokens[$nextIndex]['content'] !== '__construct' && $tokens[$nextIndex]['content'] !== '__destruct') {
            return;
        }

        $docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPtr);
        if (!$docBlockEndIndex) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];

        $firstLineIndex = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $docBlockStartIndex, $docBlockEndIndex);
        if ($tokens[$firstLineIndex]['line'] !== $tokens[$docBlockStartIndex]['line'] + 1) {
            return;
        }

        if (!preg_match('/^\w+ (constructor|destructor)\.$/i', $tokens[$firstLineIndex]['content'])) {
            return;
        }

        $fix = $phpcsFile->addFixableError('Doc Block has unneeded header line.', $firstLineIndex, 'UnneededNoise');
        if (!$fix) {
            return;
        }

        $phpcsFile->fixer->beginChangeset();

        $phpcsFile->fixer->replaceToken($firstLineIndex, '');

        $index = $firstLineIndex;
        while ($tokens[$index - 1]['line'] === $tokens[$firstLineIndex]['line']) {
            $index--;
            $phpcsFile->fixer->replaceToken($index, '');
        }
        $index = $firstLineIndex;
        while ($tokens[$index + 1]['line'] === $tokens[$firstLineIndex]['line']) {
            $index++;
            $phpcsFile->fixer->replaceToken($index, '');
        }

        $phpcsFile->fixer->endChangeset();
    }
653280
public function process(File $phpcsFile, $stackPtr)
    {
        $className = $phpcsFile->getDeclarationName($stackPtr);

        if (!$className) {
            return;
        }

        $classProperties = $phpcsFile->getClassProperties($stackPtr);
        $hasAbstractName = substr($className, 0, 8) === 'Abstract';

        if ($classProperties['is_abstract'] === true && $hasAbstractName === false) {
            $phpcsFile->addError(
                'Abstract class name "%s" is not prefixed with "Abstract"',
                $stackPtr,
                'AbstractWrongName',
                array($className)
            );
        } elseif ($classProperties['is_abstract'] === false && $hasAbstractName === true) {
            $phpcsFile->addError(
                'Non-abstract class name "%s" is prefixed with "Abstract"',
                $stackPtr,
                'AbstractMissingModifier',
                array($className)
            );
        }
    }
636341
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens          = $phpcsFile->getTokens();
        $secondTokenData = $tokens[($stackPtr + 1)];
        $thirdTokenData  = $tokens[($stackPtr + 2)];

        // This is a silenced "trigger_error" function call.
        if ($secondTokenData['code'] === T_STRING
            && $secondTokenData['content'] === 'trigger_error'
            && $thirdTokenData['code'] === T_OPEN_PARENTHESIS
            && isset($thirdTokenData['parenthesis_closer']) === true
        ) {
            $lastArgumentToken = $phpcsFile->findPrevious(
                Tokens::$emptyTokens,
                ($thirdTokenData['parenthesis_closer'] - 1),
                ($thirdTokenData['parenthesis_opener'] + 1),
                true
            );

            $lastArgumentTokenData = $tokens[$lastArgumentToken];

            if ($lastArgumentTokenData['code'] === T_STRING
                && $lastArgumentTokenData['content'] === 'E_USER_DEPRECATED'
            ) {
                return;
            }
        }

        parent::process($phpcsFile, $stackPtr);
    }
568017
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
    {
        $tokens = $phpcsFile->getTokens();

        switch ($tokens[ $stackPtr ][ 'type' ])
        {
            case T_IF:
            case T_ELSEIF:
            case T_SWITCH:
            case T_WHILE:
            case T_FOR:
            case T_FOREACH:
            case T_OPEN_PARENTHESIS:
                if ( $tokens[ $stackPtr + 1 ][ 'type' ] !== T_WHITESPACE &&
                    ($tokens[ $stackPtr + 1 ][ 'content' ] !== '\n' && $tokens[ $stackPtr
                    + 1 ] !== T_CLOSE_PARENTHESIS) )
                {
                    $error = 'Need a space after the opening parentheses';
                    $phpcsFile->addError( $error, $stackPtr );
                }
                break;

            case T_CLOSE_PARENTHESIS:
                if ( $tokens[ $stackPtr - 1 ][ 'content' ] != ' ' )
                {
                    $error = 'Need a space before the closing parentheses';
                    $phpcsFile->addError( $error, $stackPtr );
                }
                break;
            default:
                break;
        }
    }
626519
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('5.6') === false) {
            return;
        }

        $tokens       = $phpcsFile->getTokens();
        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
        if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
            return;
        }

        // Still here ? In that case, it is an anonymous class.
        $phpcsFile->addError(
            'Anonymous classes are not supported in PHP 5.6 or earlier',
            $stackPtr,
            'Found'
        );
    }
1027274
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens       = $phpcsFile->getTokens();
        $constantName = $tokens[$stackPtr]['content'];

        if (isset($this->newConstants[$constantName]) === false) {
            return;
        }

        if ($this->isUseOfGlobalConstant($phpcsFile, $stackPtr) === false) {
            return;
        }

        $itemInfo = array(
            'name' => $constantName,
        );
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
    }
246199
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.0') === false) {
            return;
        }

        $tokens         = $phpcsFile->getTokens();
        $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1));
        if ($endOfStatement === false) {
            // No semi-colon - live coding.
            return;
        }

        for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
            $errorThrown = false;
            $nextComma   = $phpcsFile->findNext(\T_COMMA, $ptr, $endOfStatement, false, null, true);
            $varEnd      = ($nextComma === false) ? $endOfStatement : $nextComma;
            $variable    = $phpcsFile->findNext(\T_VARIABLE, $ptr, $varEnd);
            $varString   = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr)));
            $data        = array($varString);

            if ($variable !== false) {

                $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($variable - 1), $ptr, true);

                if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') {

                    $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($variable + 1), $varEnd, true);

                    if ($next !== false
                        && \in_array($tokens[$next]['code'], array(\T_OPEN_SQUARE_BRACKET, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === true
                    ) {
                        $phpcsFile->addError(
                            'Global with variable variables is not allowed since PHP 7.0. Found %s',
                            $variable,
                            'Found',
                            $data
                        );
                        $errorThrown = true;
                    } else {
                        $phpcsFile->addWarning(
                            'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
                            $variable,
                            'NonBareVariableFound',
                            $data
                        );
                        $errorThrown = true;
                    }
                }
            }

            if ($errorThrown === false) {
                $dollar = $phpcsFile->findNext(\T_DOLLAR, $ptr, $varEnd);
                if ($dollar !== false) {
                    $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($dollar + 1), $varEnd, true);
                    if ($tokens[$next]['code'] === \T_OPEN_CURLY_BRACKET) {
                        $phpcsFile->addWarning(
                            'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s',
                            $dollar,
                            'NonBareVariableFound',
                            $data
                        );
                    }
                }
            }

            // Move the stack pointer forward to the next variable for multi-variable statements.
            if ($nextComma === false) {
                break;
            }
            $ptr = $nextComma;
        }
    }
724912
public function process(File $phpcsFile, $stackPtr)
    {
        $algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
        if (empty($algo) || \is_string($algo) === false) {
            return;
        }

        // Bow out if not one of the algorithms we're targetting.
        if (isset($this->newAlgorithms[$algo]) === false) {
            return;
        }

        // Check if the algorithm used is new.
        $itemInfo = array(
            'name'   => $algo,
        );
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
    }
304679
public function process(File $phpcsFile, $stackPtr)
    {
        /*
         * Due to a tokenizer bug which gets hit when the PHP 7.3 heredoc/nowdoc syntax
         * is used, this part of the sniff cannot possibly work on PHPCS < 2.6.0.
         * See upstream issue #928.
         */
        if ($this->supportsBelow('7.2') === true && version_compare(PHPCSHelper::getVersion(), '2.6.0', '>=')) {
            $this->detectIndentedNonStandAloneClosingMarker($phpcsFile, $stackPtr);
        }

        $tokens = $phpcsFile->getTokens();
        if ($this->supportsAbove('7.3') === true && $tokens[$stackPtr]['code'] !== \T_STRING) {
            $this->detectClosingMarkerInBody($phpcsFile, $stackPtr);
        }
    }