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

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

@return void
17486
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.3') === false) {
            return;
        }

        $tokens  = $phpcsFile->getTokens();
        $varName = substr($tokens[$stackPtr]['content'], 1);

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

        if ($this->isClassProperty($phpcsFile, $stackPtr) === true) {
            // Ok, so this was a class property declaration, not our concern.
            return;
        }

        // Check for static usage of class properties shadowing the removed global variables.
        if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) {
            $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
            if ($prevToken !== false && $tokens[$prevToken]['code'] === \T_DOUBLE_COLON) {
                return;
            }
        }

        // Do some additional checks for the $php_errormsg variable.
        if ($varName === 'php_errormsg'
            && $this->isTargetPHPErrormsgVar($phpcsFile, $stackPtr, $tokens) === false
        ) {
            return;
        }

        // Still here, so throw an error/warning.
        $itemInfo = array(
            'name' => $varName,
        );
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
    }
150545
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('7.0') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();
        $token  = $tokens[$stackPtr];

        // Bow out during live coding.
        if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) {
            return;
        }

        $hasBitwiseOr = $phpcsFile->findNext(\T_BITWISE_OR, $token['parenthesis_opener'], $token['parenthesis_closer']);

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

        $phpcsFile->addError(
            'Catching multiple exceptions within one statement is not supported in PHP 7.0 or earlier.',
            $hasBitwiseOr,
            'Found'
        );
    }
834171
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE
            && $tokens[($stackPtr - 2)]['line'] === $tokens[$stackPtr]['line']
        ) {
            $error = 'Space found before object operator';
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Before');
            if ($fix === true) {
                $phpcsFile->fixer->replaceToken(($stackPtr - 1), '');
            }
        }

        if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE
            && $tokens[($stackPtr + 2)]['line'] === $tokens[$stackPtr]['line']
        ) {
            $error = 'Space found after object operator';
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'After');
            if ($fix === true) {
                $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
            }
        }
    }
641177
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens = $phpcsFile->getTokens();
		
		// Only work on level 1 "use", means including traits
		if ($tokens[$stackPtr]['level' ] != 1) {
			return;
		}

		$nextComma = $phpcsFile->findNext(T_COMMA, $stackPtr);
		$nextSemi = $phpcsFile->findNext(T_SEMICOLON, $stackPtr);

		if ($nextComma !== false && $nextComma < $nextSemi) {
			$error = 'Only one trait should be included per "use"';
			$phpcsFile->addError($error, $stackPtr, 'OnlyOneTraitPerUse');
		}
	}
1010511
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.0') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
            if ($this->isShortList($phpcsFile, $stackPtr) === false) {
                return;
            }

            $open  = $stackPtr;
            $close = $tokens[$stackPtr]['bracket_closer'];
        } else {
            // T_LIST.
            $open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
            if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
                return;
            }

            $close = $tokens[$open]['parenthesis_closer'];
        }

        $error = true;
        if (($close - $open) > 1) {
            for ($cnt = $open + 1; $cnt < $close; $cnt++) {
                if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
                    $error = false;
                    break;
                }
            }
        }

        if ($error === true) {
            $phpcsFile->addError(
                'Empty list() assignments are not allowed since PHP 7.0',
                $stackPtr,
                'Found'
            );
        }
    }
453423
public function process(File $phpcsFile, $stackPtr)
    {
        parent::process($phpcsFile, $stackPtr);

        $tokens = $phpcsFile->getTokens();
        $find   = Tokens::$methodPrefixes;
        $find[] = T_WHITESPACE;

        $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
        if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG) {
            return;
        }

        $commentStart = $tokens[$commentEnd]['comment_opener'];

        $empty = array(
                  T_DOC_COMMENT_WHITESPACE,
                  T_DOC_COMMENT_STAR,
                 );

        $short = $phpcsFile->findNext($empty, ($commentStart + 1), $commentEnd, true);
        if ($short === false || $tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
            return;
        }

        if ($this->isInheritDoc($phpcsFile, $commentStart) === true) {
            return;
        }

        $this->checkShort($phpcsFile, $stackPtr, $tokens[$short]['content'], $short);
    }
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);
        }
    }
300164
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $ignore = array(
            \T_DOUBLE_COLON    => true,
            \T_OBJECT_OPERATOR => true,
            \T_FUNCTION        => true,
            \T_CONST           => 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;
        }

        $functionLc = strtolower($tokens[$stackPtr]['content']);
        if (isset($this->iniFunctions[$functionLc]) === false) {
            return;
        }

        $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
        if ($iniToken === false) {
            return;
        }

        $filteredToken = $this->stripQuotes($iniToken['raw']);
        if (isset($this->newIniDirectives[$filteredToken]) === false) {
            return;
        }

        $itemInfo = array(
            'name'       => $filteredToken,
            'functionLc' => $functionLc,
        );
        $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
    }
282251
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
		$tokens = $phpcsFile->getTokens();

		if ( $tokens[( $stackPtr + 1 )]['code'] !== T_WHITESPACE
			&& ! ( $tokens[$stackPtr]['code'] === T_ELSE && $tokens[( $stackPtr + 1 )]['code'] === T_COLON )
			&& ! ( T_CLOSURE === $tokens[ $stackPtr ]['code'] && 0 === (int) $this->spaces_before_closure_open_paren )
		) {
			$error = 'Space after opening control structure is required';

			if ( isset( $phpcsFile->fixer ) === true ) {
				$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );

				if ( $fix === true ) {
					$phpcsFile->fixer->beginChangeset();
					$phpcsFile->fixer->addContent( $stackPtr, ' ' );
					$phpcsFile->fixer->endChangeset();
				}
			} else {
				$phpcsFile->addError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );
			}
		}

		if ( isset( $tokens[ $stackPtr ] ) && isset( $tokens[ $stackPtr ]['scope_closer'] ) === false ) {
			if ( T_USE === $tokens[ $stackPtr ]['code'] ) {
				$scopeOpener = $phpcsFile->findNext( T_OPEN_CURLY_BRACKET, $stackPtr + 1 );
				$scopeCloser = isset( $tokens[ $scopeOpener ]['scope_closer'] ) ? $tokens[ $scopeOpener ]['scope_closer'] : null;
			} else {
				return;
			}
		} else {
			$scopeOpener = isset( $tokens[ $stackPtr ]['scope_opener'] ) ? $tokens[ $stackPtr ]['scope_opener'] : null;
			$scopeCloser = isset( $tokens[ $stackPtr ]['scope_closer'] ) ? $tokens[ $stackPtr ]['scope_closer'] : null;
		}

		$firstContent = $phpcsFile->findNext( T_WHITESPACE, ( $scopeOpener + 1 ), null, true );
		$currentToken = $tokens[$scopeOpener];
		$class_line = array_values( array_filter( array_filter( $tokens, function ( $token ) use( $currentToken ) {
			return $token['line'] === $currentToken['line'];
		} ), function ( $token ) {
			return $token['code'] === T_CLASS;
		} ) );

		if ( count( $class_line ) > 0 ) {
			$next_line = array_filter( $tokens, function ( $token ) use( $class_line ) {
				return $token['line'] === $class_line[0]['line'] + 1;
			} );

			if ( count( $next_line ) > 0 ) {
				$whitespace = array_filter( $next_line, function ( $token ) {
					return $token['code'] === T_WHITESPACE;
				} );

				$whitespace = count( $whitespace ) < count( $next_line );

				if ( $whitespace
					&& $tokens[$scopeOpener]['code'] === T_OPEN_CURLY_BRACKET
					&& ! isset( $tokens[$firstContent]['nested_parenthesis'] )
					&& $tokens[$firstContent]['level'] === 1
				) {
					$error = 'No blank line found at start of control structure';

					if ( isset( $phpcsFile->fixer ) === true ) {
						$fix = $phpcsFile->addFixableError( $error, $scopeOpener, 'NoBlankLineAfterStart' );

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

							for ( $i = ( $scopeOpener + 2 ); $i < $firstContent; $i++ ) {
								$phpcsFile->fixer->replaceToken( $i, '' );
							}

							$phpcsFile->fixer->addNewline( $scopeOpener );
							$phpcsFile->fixer->endChangeset();
						}
					} else {
						$phpcsFile->addError( $error, $scopeOpener, 'NoBlankLineAfterStart' );
					}
				}

				$next_line = array_values( $next_line );

				$next_next_line = array_filter( $tokens, function ( $token ) use ( $next_line ) {
					return $token['line'] === $next_line[0]['line'] + 1;
				} );

				if ( count( $next_next_line )  > 0 ) {
					$next_whitespace = array_filter( $next_next_line, function ( $token ) {
						return $token['code'] === T_WHITESPACE;
					} );

					$next_whitespace = count( $next_next_line ) === count( $next_whitespace );

					if ( $next_whitespace
						&& $tokens[$scopeOpener]['code'] === T_OPEN_CURLY_BRACKET
						&& ! isset( $tokens[$firstContent]['nested_parenthesis'] )
						&& $tokens[$firstContent]['level'] === 1
					) {
						$error = 'More then one blank line found at start of control structure';

						if ( isset( $phpcsFile->fixer ) === true ) {
							$fix = $phpcsFile->addFixableError( $error, $scopeOpener, 'MoreThenOneBlankLineAfterStart' );

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

								for ( $i = ( $scopeOpener + 2 ); $i < $firstContent; $i++ ) {
									$phpcsFile->fixer->replaceToken( $i, '' );
								}

								$phpcsFile->fixer->addNewline( $scopeOpener );
								$phpcsFile->fixer->endChangeset();
							}
						} else {
							$phpcsFile->addError( $error, $scopeOpener, 'MoreThenOneBlankLineAfterStart' );
						}
					}
				}
			}
		}

		$trailingContent = $phpcsFile->findNext( T_WHITESPACE, ( $scopeCloser + 1 ), null, true );

		if ( $tokens[$trailingContent]['code'] === T_ELSE ) {
			if ( $tokens[$stackPtr]['code'] === T_IF ) {
				// IF with ELSE.
				return;
			}
		}

		if ( $tokens[$trailingContent]['code'] === T_COMMENT ) {
			if ( $tokens[$trailingContent]['line'] === $tokens[$scopeCloser]['line'] ) {
				if ( substr( $tokens[$trailingContent]['content'], 0, 5 ) === '//end' ) {
					// There is an end comment, so we have to get the next piece
					// of content.
					$trailingContent = $phpcsFile->findNext( T_WHITESPACE, ( $trailingContent + 1 ), null, true );
				}
			}
		}

		if ( $tokens[$trailingContent]['code'] === T_BREAK ) {
			// If this BREAK is closing a CASE, we don't need the
			// blank line after this control structure.
			if ( isset( $tokens[$trailingContent]['scope_condition'] ) === true ) {
				$condition = $tokens[$trailingContent]['scope_condition'];

				if ( $tokens[$condition]['code'] === T_CASE || $tokens[$condition]['code'] === T_DEFAULT ) {
					return;
				}
			}
		}
	}
41979
public function process(File $phpcsFile, $stackPtr) {
		$tokens = $phpcsFile->getTokens();
		$s = $phpcsFile->findNext(\PHP_CodeSniffer\Util\Tokens::$stringTokens, $stackPtr + 1);
		if (preg_match('/\.(\w+)(?:\'|\")$/', $tokens[$s]['content'], $matches)) {
			$ext = $matches[1];
			if (!array_key_exists($ext, $phpcsFile->config->extensions)) {
				$phpcsFile->addError("The file extension '.$ext' that is not specified by --extensions has been used in a include/require function. Please add it to the scan process.", $stackPtr, 'ErrMiscIncludeMismatch');
			}
		} else {
			$phpcsFile->addError("No file extension has been found in a include/require function. This implies that some PHP code is not scanned by PHPCS.", $stackPtr, 'ErrMiscIncludeMismatchNoExt');
		}
	}
1107269
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $token = $tokens[$stackPtr];

        if (!array_key_exists('scope_opener', $token) || !array_key_exists('scope_closer', $token)) {
            return;
        }

        $scopeOpener = $token['scope_opener'];
        $firstContent = $phpcsFile->findNext(T_WHITESPACE, $scopeOpener + 1, null, true);

        if ($tokens[$firstContent]['line'] !== $tokens[$scopeOpener]['line'] + 1) {
            $phpcsFile->addError('Blank line found at start of control structure', $scopeOpener, 'SpacingBeforeOpen');
        }

        $scopeCloser = $token['scope_closer'];
        $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, $scopeCloser - 1, null, true);

        if ($tokens[$lastContent]['line'] !== $tokens[$scopeCloser]['line'] - 1) {
            $phpcsFile->addError('Blank line found at end of control structure', $lastContent + 2, 'SpacingAfterClose');
        }
    }
1257356
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
            return;
        }

        $errorData = array(strtolower($tokens[$stackPtr]['content']));

        $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_TRAIT), ($stackPtr + 1));
        if ($nextClass !== false) {
            $error = 'Each %s must be in a file by itself';
            $phpcsFile->addError($error, $nextClass, 'MultipleClasses', $errorData);
        }
    }
992308
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('5.4') === false) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        if (strtolower($tokens[$stackPtr]['content']) !== 'class') {
            return;
        }

        $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
        if ($prevToken === false || $tokens[$prevToken]['code'] !== \T_DOUBLE_COLON) {
            return;
        }

        $phpcsFile->addError(
            'The magic class constant ClassName::class was not available in PHP 5.4 or earlier',
            $stackPtr,
            'Found'
        );
    }
961690
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        // Check decrement / increment.
		if ($tokens[$stackPtr]['code'] === T_DEC || $tokens[$stackPtr]['code'] === T_INC)
		{
            $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 a unary operator statement';
                $phpcsFile->addError($error, $stackPtr, 'IncDecLeft');
                return;
            }

			if ($modifyLeft === false && !in_array(substr($tokens[($stackPtr + 1)]['content'], 0, 1), array('$', ',')))
			{
                $error = 'A unary operator statement must not be followed by a single space';
                $phpcsFile->addError($error, $stackPtr, 'IncDecRight');
                return;
            }
        }

        // Check "!" operator.
		if ($tokens[$stackPtr]['code'] === T_BOOLEAN_NOT && $tokens[$stackPtr + 1]['code'] === T_WHITESPACE)
		{
            $error = 'A unary operator statement must not be followed by a space';
            $phpcsFile->addError($error, $stackPtr, 'BooleanNot');
            return;
        }

        // Find the last syntax item to determine if this is an unary operator.
        $lastSyntaxItem = $phpcsFile->findPrevious(
            array(T_WHITESPACE),
            $stackPtr - 1,
            ($tokens[$stackPtr]['column']) * -1,
            true,
            null,
            true
        );
        $operatorSuffixAllowed = in_array(
            $tokens[$lastSyntaxItem]['code'],
            array(
             T_LNUMBER,
             T_DNUMBER,
             T_CLOSE_PARENTHESIS,
             T_CLOSE_CURLY_BRACKET,
             T_CLOSE_SQUARE_BRACKET,
             T_VARIABLE,
             T_STRING,
            )
        );

        // Check plus / minus value assignments or comparisons.
		if ($tokens[$stackPtr]['code'] === T_MINUS || $tokens[$stackPtr]['code'] === T_PLUS)
		{
            if ($operatorSuffixAllowed === false
                && $tokens[($stackPtr + 1)]['code'] === T_WHITESPACE
			)
			{
                $error = 'A unary operator statement must not be followed by a space';
                $phpcsFile->addError($error, $stackPtr);
            }
        }

    }
1305612
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if ($tokens[$stackPtr -1]['code'] !== T_WHITESPACE
            || $tokens[$stackPtr +1]['code'] !== T_WHITESPACE
        ) {
            $fix = $phpcsFile->addFixableError(
                'Add a single space around binary operators',
                $stackPtr,
                'Invalid'
            );

            if ($fix === true) {
                if ($tokens[$stackPtr -1]['code'] !== T_WHITESPACE) {
                    $phpcsFile->fixer->addContentBefore($stackPtr, " ");
                }

                if ($tokens[$stackPtr +1]['code'] !== T_WHITESPACE) {
                    $phpcsFile->fixer->addContent($stackPtr, " ");
                }
            }
        }
    }
569051
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);

        $isSingleLine = $tokens[$arrayStart]['line'] === $tokens[$arrayEnd]['line'];

        $commas = DWS_Helpers_Array::commaPositions($phpcsFile, $arrayStart);

        $lastComma = array_pop($commas);
        $trailingComma = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $lastComma + 1, $arrayEnd, true) === false;

        if ($isSingleLine) {
            if ($trailingComma) {
                $phpcsFile->addError('No trailing comma allowed on single-line arrays', $lastComma, 'SingleLineTrailingComma');
            }
        } elseif (!$trailingComma) {
            $previousItem = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $arrayEnd - 1, $arrayStart, true);
            $phpcsFile->addError('Trailing comma required for multi-line arrays', $previousItem, 'MultiLineTrailingComma');
        }
    }
897878
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $line   = $tokens[$stackPtr]['line'];

        if ($tokens[$stackPtr + 1]['line'] === $line
            && $tokens[$stackPtr + 1]['code'] !== T_WHITESPACE
        ) {
            $fix = $phpcsFile->addFixableError(
                'Add a single space after each comma delimiter',
                $stackPtr,
                'Invalid'
            );

            if ($fix === true) {
                $phpcsFile->fixer->addContent($stackPtr, " ");
            }
        }
    }