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

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

@return void
772670
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $errorData = array($tokens[$stackPtr]['content']);
        // braces
        $openingBrace = $tokens[$stackPtr]['scope_opener'];
        $closingBrace = $tokens[$stackPtr]['scope_closer'];
        // look for empty bodies
        $body = $phpcsFile->getTokensAsString(
            $openingBrace, $closingBrace - $openingBrace + 1
        );
        if (preg_match('/^\{\s*\}$/', $body)) {
            if (preg_match('/\s/', $body)) {
                $error = 'Opening and closing braces of an empty %s must be on ' . 
                    'the same line as the definition, with no spaces between them.';
                $phpcsFile->addError(
                    $error, $stackPtr, 'EmptyBodyBraces', $errorData
                );
            }
            // body has content
        } else {
            parent::process($phpcsFile, $stackPtr);
            // check braces alignment
            if ($tokens[$openingBrace]['column'] !== $tokens[$closingBrace]['column']) {
                $error = 'Closing braces must have the same indentation than ' .
                    'their respective opening one.';
                $phpcsFile->addError(
                    $error, $closingBrace, 'BadClosingBraceIndentation', $errorData
                );
            }
        }
    }
757060
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[($stackPtr + 1)]) === false)
        {
            return;
        }

        // Single space after the keyword.
        $found = 1;

        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE)
        {
            $found = 0;
        }
        elseif ($tokens[($stackPtr + 1)]['content'] !== ' ')
        {
            if (strpos($tokens[($stackPtr + 1)]['content'], $phpcsFile->eolChar) !== false)
            {
                $found = 'newline';
            }
            else
            {
                $found = strlen($tokens[($stackPtr + 1)]['content']);
            }
        }

        if ($found !== 1
            && $tokens[($stackPtr)]['code'] !== T_ELSE
            && $tokens[($stackPtr)]['code'] !== T_TRY
            && $tokens[($stackPtr)]['code'] !== T_DO
            && $tokens[($stackPtr)]['code'] !== T_FINALLY
        )
        {
            $error = 'Expected 1 space after %s keyword; %s found';
            $data  = [
                      strtoupper($tokens[$stackPtr]['content']),
                      $found,
                     ];
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data);

            if ($fix === true)
            {
                if ($found === 0)
                {
                    $phpcsFile->fixer->addContent($stackPtr, ' ');
                }
                else
                {
                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
                }
            }
        }

        // Single newline after opening brace.
        if (isset($tokens[$stackPtr]['scope_opener']) === true)
        {
            $opener = $tokens[$stackPtr]['scope_opener'];

            for ($next = ($opener + 1); $next < $phpcsFile->numTokens; $next++)
            {
                $code = $tokens[$next]['code'];

                if ($code === T_WHITESPACE)
                {
                    continue;
                }

                // Skip all empty tokens on the same line as the opener.
                if ($tokens[$next]['line'] === $tokens[$opener]['line']
                    && (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true
                    || $code === T_CLOSE_TAG)
                )
                {
                    continue;
                }

                // We found the first bit of a code, or a comment on the
                // following line.
                break;
            }

            $found = ($tokens[$next]['line'] - $tokens[$opener]['line']);

            if ($found !== 1)
            {
                $error = 'Expected 1 newline after opening brace; %s found';
                $data  = [$found];
                $fix   = $phpcsFile->addFixableError($error, $opener, 'NewlineAfterOpenBrace', $data);

                if ($fix === true)
                {
                    $phpcsFile->fixer->beginChangeset();

                    for ($i = ($opener + 1); $i < $next; $i++)
                    {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$next]['line'])
                        {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($opener, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }
        }
        elseif ($tokens[$stackPtr]['code'] === T_WHILE)
        {
            // Zero spaces after parenthesis closer.
            $closer = $tokens[$stackPtr]['parenthesis_closer'];
            $found  = 0;

            if ($tokens[($closer + 1)]['code'] === T_WHITESPACE)
            {
                if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false)
                {
                    $found = 'newline';
                }
                else
                {
                    $found = strlen($tokens[($closer + 1)]['content']);
                }
            }

            if ($found !== 0)
            {
                $error = 'Expected 0 spaces before semicolon; %s found';
                $data  = [$found];
                $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceBeforeSemicolon', $data);

                if ($fix === true)
                {
                    $phpcsFile->fixer->replaceToken(($closer + 1), '');
                }
            }
        }//end if

        // Only want to check multi-keyword structures from here on.
        if ($tokens[$stackPtr]['code'] === T_DO)
        {
            if (isset($tokens[$stackPtr]['scope_closer']) === false)
            {
                return;
            }

            $closer = $tokens[$stackPtr]['scope_closer'];
        }
        elseif ($tokens[$stackPtr]['code'] === T_ELSE
            || $tokens[$stackPtr]['code'] === T_ELSEIF
            || $tokens[$stackPtr]['code'] === T_CATCH
        )
        {
            $closer = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);

            if ($closer === false || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET)
            {
                return;
            }
        }
        else
        {
            return;
        }

        // Own line for do, else, elseif, catch and no white space after closing brace
        $found = 0;

        if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
            && $tokens[($closer + 1)]['content'] !== $phpcsFile->eolChar
        )
        {
            $found = strlen($tokens[($closer + 1)]['content']);
        }

        if (0 !== $found)
        {
            $error = 'Expected 0 space after closing brace; %s found';
            $data  = [$found];
            $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data);

            if (true === $fix)
            {
                $phpcsFile->fixer->replaceToken(($closer + 1), '' . $phpcsFile->eolChar);
            }
        }

        if ($tokens[($closer + 1)]['content'] !== $phpcsFile->eolChar && 0 === $found)
        {
            $error  = 'Definition of do,else,elseif,catch must be on their own line.';
            $fix    = $phpcsFile->addFixableError($error, $closer, 'NewLineAfterCloseBrace');
            $blanks = substr($tokens[($closer - 1)]['content'], strpos($tokens[($closer - 1)]['content'], $phpcsFile->eolChar));
            $spaces = str_repeat(' ', strlen($blanks));

            if (true === $fix)
            {
                $phpcsFile->fixer->beginChangeset();
                $phpcsFile->fixer->addContent($closer, $phpcsFile->eolChar);
                $phpcsFile->fixer->addContentBefore(($closer + 1), $spaces);
                $phpcsFile->fixer->endChangeset();
            }
        }
    }
1343355
public function process(File $phpcsFile, $stackPtr) {
		$tokens = $phpcsFile->getTokens();

		if ($tokens[($stackPtr + 1)]['code'] == T_WHITESPACE && $tokens[($stackPtr + 2)]['code'] == T_IF) {
			$message = 'Detected else if. Use elseif instead.';
			$phpcsFile->addError($message, $stackPtr, 'Missing');
		}

	}
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);
        }
    }
138727
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->bowOutEarly() === true) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
            && $this->isShortList($phpcsFile, $stackPtr) === false
        ) {
            // Short array, not short list.
            return;
        }

        if ($tokens[$stackPtr]['code'] === \T_LIST) {
            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
            if ($nextNonEmpty === false
                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
            ) {
                // Parse error or live coding.
                return;
            }

            $opener = $nextNonEmpty;
            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
        } else {
            // Short list syntax.
            $opener = $stackPtr;

            if (isset($tokens[$stackPtr]['bracket_closer'])) {
                $closer = $tokens[$stackPtr]['bracket_closer'];
            }
        }

        if (isset($opener, $closer) === false) {
            return;
        }

        $this->examineList($phpcsFile, $opener, $closer);
    }
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;
        }
    }
602320
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $arrayStart = DWS_Helpers_Bracket::bracketStart($phpcsFile, $stackPtr);
        $arrayEnd = DWS_Helpers_Bracket::bracketEnd($phpcsFile, $stackPtr);

        if (!in_array($arrayStart, [$stackPtr, $stackPtr + 1])) {
            $phpcsFile->addError('No whitespace allowed between the array keyword and the opening parenthesis', $stackPtr, 'SpaceAfterKeyword');
        }

        $firstMember = $phpcsFile->findNext(T_WHITESPACE, $arrayStart + 1, $arrayEnd, true);
        if ($firstMember === false && $arrayEnd - $arrayStart !== 1) {
            $phpcsFile->addError('Empty array declaration must have no space between the brackets', $stackPtr, 'SpaceInEmptyArray');
        }
    }
1196437
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $stackPrev = $stackPtr - 1;
        $stackNext = $stackPtr + 1;

        // One space after the namespace keyword.
        if ($tokens[$stackNext]['content'] !== ' ') {
            $error = 'There must be a single space after the NAMESPACE keyword';
            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterNamespace');
            if ($fix === true) {
                $phpcsFile->fixer->replaceToken($stackNext, ' ');
            }
        }

        // Find the previous token that is NOT whitespace
        $lastNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, $stackPrev, null, true);

        // should not happen; something is horribly wrong
        if ($lastNonWhitespace === false) {
            return;
        }

        $diff = ($tokens[$stackPtr]['line'] - $tokens[$lastNonWhitespace]['line']);

        if ($diff !== 2) {
            $error = 'There must be one blank line before the namespace declaration';
            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'BlankLineBefore');

            if ($fix === true) {
                /*
                 * If there is less than a 2 line difference, add newlines in.
                 * If there is more than a 2 line difference, take newlines out.
                 */
                if ($diff < 2) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = 0; $i < (2 - $diff); $i++) {
                        $phpcsFile->fixer->addNewlineBefore($stackPtr);
                    }
                    $phpcsFile->fixer->endChangeset();
                } else {
                    /*
                     * Remove all whitespace between the namespace and the previous non-whitespace
                     * tokens. If a newline was removed from the same line as the previous
                     * non-whitespace token, we need to make sure to add that back in.
                     */
                    $phpcsFile->fixer->beginChangeset();
                    $newlineRemoved = false;
                    for ($i = ($lastNonWhitespace + 1); $i < $stackPtr; $i++) {
                        if ($tokens[$lastNonWhitespace]['line'] === $tokens[$i]['line']) {
                            $newlineRemoved = true;
                        }
                        $phpcsFile->fixer->replaceToken($i, '');
                    }
                    if ($newlineRemoved) {
                        $phpcsFile->fixer->addNewline($lastNonWhitespace);
                    }
                    $phpcsFile->fixer->addNewline($lastNonWhitespace);
                    $phpcsFile->fixer->endChangeset();
                }
            }
        } elseif ($tokens[$stackPtr]['column'] !== 1) {
            $error = 'Line indented incorrectly; expected 0 spaces, found '.($tokens[$stackPtr]['column'] - 1);
            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceBeforeNamespace');

            if ($fix === true) {
                $content = explode("\n", $tokens[$stackPrev]['content']);
                $content[count($content) - 1] = '';
                $phpcsFile->fixer->replaceToken($stackPrev, implode("\n", $content));
            }
        }
    }
902342
public function process(File $phpcsFile, $stackPtr)
    {
        $this->checkContent($phpcsFile, $stackPtr, true);
        $this->checkContent($phpcsFile, $stackPtr, false);
    }
234659
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $methodProperties = $phpcsFile->getMethodProperties($stackPtr);
        if ($methodProperties['scope'] !== 'public') {
            return;
        }

        parent::process($phpcsFile, $stackPtr);
    }
747366
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
        if (
            is_null(PHP_CodeSniffer::getConfigData('testVersion'))
            ||
            (
                !is_null(PHP_CodeSniffer::getConfigData('testVersion'))
                &&
                version_compare(PHP_CodeSniffer::getConfigData('testVersion'), '5.4') >= 0
            )
        ) {
            $tokens = $phpcsFile->getTokens();
            $openBracket  = $tokens[$stackPtr]['parenthesis_opener'];
            $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];

            for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
                $variable = $tokens[$i]['content'];
                if (in_array($variable, $this->superglobals)) {
                    $phpcsFile->addError("Parameter shadowing super global ($variable) causes fatal error since PHP 5.4", $i);
                }
            }
            
        }
    }
518384
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.4')) {
            $tokens = $phpcsFile->getTokens();
            $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
            for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
                $gotError = false;
                if ($tokens[$curToken]['type'] == 'T_STRING') {
                    // If the next non-whitespace token after the string
                    // is an opening parenthesis then it's a function call.
                    $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
                    if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
                        continue;
                    } else {
                        $gotError = true;
                    }
                }
                switch ($tokens[$curToken]['type']) {
                    case 'T_VARIABLE':
                    case 'T_FUNCTION':
                        $gotError = true;
                        break;
                }
                if ($gotError === true) {
                    $error = 'Using a variable argument on break or continue is forbidden since PHP 5.4';
                    $phpcsFile->addError($error, $stackPtr);
                }
            }
        }
    }
1040220
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens = $phpcsFile->getTokens();
		
		// That's not a class variable so ignore it
		if ($tokens[$stackPtr]['level'] != 1) {
			return;
		}
		
		$visibility = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr);
		// Not the same line, not our modifier. PSR-2 will throw an error in that case so ignore it
		if ($tokens[$visibility]['line'] !== $tokens[$stackPtr]['line']) {
			return;
		}

		$function = $phpcsFile->findPrevious(T_FUNCTION, $stackPtr);
		// We don't want to react on functions (public function xy ($var))
		if ($function > $visibility) {
			return;
		}
		
		$modifier = $tokens[$visibility]['code'];
		
		$data = array(trim($tokens[$stackPtr]['content']));

		if ($modifier != T_PRIVATE && $modifier != T_PROTECTED) {
			$error = '%s must be "private" or "protected"';
			$phpcsFile->addError($error, $stackPtr, 'NotPrivateOrProtected', $data);
		}
	}
1001661
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $arrayToken = $tokens[$stackPtr];
        $closeParenthesisPointer = $arrayToken['bracket_closer'];
        /** @var int $previousToCloseParenthesisPointer */
        $previousToCloseParenthesisPointer = TokenHelper::findPreviousEffective($phpcsFile, $closeParenthesisPointer - 1);
        $previousToCloseParenthesisToken = $tokens[$previousToCloseParenthesisPointer];

        if ($previousToCloseParenthesisToken['code'] !== T_COMMA) {
            return;
        }

        $fix = $phpcsFile->addFixableError(
            'Forbidden trailing comma after the last element.',
            $previousToCloseParenthesisPointer,
            'ForbiddenArrayTrailingComma'
        );

        if ($fix === false) {
            return;
        }

        $phpcsFile->fixer->beginChangeset();
        $phpcsFile->fixer->replaceToken($previousToCloseParenthesisPointer, '');
        $phpcsFile->fixer->endChangeset();
    }
957083
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        /**
         * We distinguish between the class, function and namespace names or the define statements
         */
        if ($tokens[$stackPtr]['type'] == 'T_STRING') {
            $this->processString($phpcsFile, $stackPtr, $tokens);
        } else {
            $this->processNonString($phpcsFile, $stackPtr, $tokens);
        }
    }
562782
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        // In case we have more than one class/interface/trait
        // per file, we want to reset at the start of each.
        if ($tokens[$stackPtr]['code'] !== T_FUNCTION) {
            $this->lastMethodName = null;
            return;
        }

        // We only care about class methods, so ignore global functions (level 0).
        if ($tokens[$stackPtr]['level'] === 1) {
            $methodName = $phpcsFile->getDeclarationName($stackPtr);
            if ($this->lastMethodName !== null && $methodName <= $this->lastMethodName) {
                $phpcsFile->addError('Method "%s" is not in alphabetical order.', $stackPtr, 'OutOfOrder', [$methodName]);
            }

            $this->lastMethodName = $methodName;
        }

    }
1373368
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('5.2') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        // Get next non-whitespace token, and check it isn't the related inline else
        // symbol, which is not allowed prior to PHP 5.3.
        $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);

        if ($next !== false && $tokens[$next]['code'] === \T_INLINE_ELSE) {
            $phpcsFile->addError(
                'Middle may not be omitted from ternary operators in PHP < 5.3',
                $stackPtr,
                'MiddleMissing'
            );
        }
    }