@param \PHP_CodeSniffer\Files\File $phpcsFile
@param int $stackPtr

@return void
351940
protected function checkTryToken(File $phpcsFile, int $stackPtr): void
    {
        $tokens = $phpcsFile->getTokens();

        if ($tokens[$stackPtr]['code'] !== T_TRY) {
            return;
        }

        $this->expectSingleSpaceAfter($phpcsFile, $stackPtr, 'try');
    }
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'
        );
    }
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'
            );
        }
    }
737507
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        if (
            $tokens[$stackPtr + 2]['type'] == 'T_STRING'
            &&
            (
                $tokens[$stackPtr + 3]['type'] == 'T_OPEN_PARENTHESIS'
                ||
                (
                    $tokens[$stackPtr + 3]['type'] == 'T_WHITESPACE'
                    &&
                    $tokens[$stackPtr + 4]['type'] == 'T_OPEN_PARENTHESIS'
                )
            )
        ) {
            $className = $tokens[$stackPtr + 2]['content'];
            if (array_key_exists($className, $this->newClasses) === false) {
                return;
            }
            $this->addError($phpcsFile, $stackPtr, $className);
        }



    }
220588
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens    = $phpcsFile->getTokens();
        $errorData = [strtolower($tokens[$stackPtr]['content'])];

        if (false === isset($tokens[$stackPtr]['scope_opener']))
        {
            // @todo sort while thing...
            if ($tokens[$stackPtr]['code'] !== T_WHILE)
            {
                $error = 'Possible parse error: %s missing opening or closing brace';
                $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData);
            }

            return;
        }

        $curlyBrace  = $tokens[$stackPtr]['scope_opener'];
        $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true);
        $classLine   = $tokens[$lastContent]['line'];
        $braceLine   = $tokens[$curlyBrace]['line'];

        if ($braceLine === $classLine)
        {
            $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'same line');
            $error = 'Opening brace of a %s must be on the line after the definition';
            $fix   = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNewLine', $errorData);

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

                if (T_WHITESPACE === $tokens[($curlyBrace - 1)]['code'])
                {
                    $phpcsFile->fixer->replaceToken(($curlyBrace - 1), '');
                }

                $phpcsFile->fixer->addNewlineBefore($curlyBrace);
                $phpcsFile->fixer->endChangeset();
            }

            return;
        }
        else
        {
            $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'new line');

            if ($braceLine > ($classLine + 1))
            {
                $error = 'Opening brace of a %s must be on the line following the %s declaration.; Found %s line(s).';
                $data  = [
                          $tokens[$stackPtr]['content'],
                          $tokens[$stackPtr]['content'],
                          ($braceLine - $classLine - 1),
                         ];
                $fix   = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data);

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

                    for ($i = ($curlyBrace - 1); $i > $lastContent; $i--)
                    {
                        if ($tokens[$i]['line'] === ($tokens[$curlyBrace]['line'] + 1))
                        {
                            break;
                        }

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

                    $phpcsFile->fixer->endChangeset();
                }

                return;
            }
        }

        if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar)
        {
            $error = 'Opening %s brace must be on a line by itself.';
            $fix   = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData);

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

        if (T_WHITESPACE === $tokens[($curlyBrace - 1)]['code'])
        {
            $prevContent = $tokens[($curlyBrace - 1)]['content'];

            if ($prevContent === $phpcsFile->eolChar)
            {
                $spaces = 0;
            }
            else
            {
                $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar));
                $spaces     = strlen($blankSpace);
            }

            $expected = ($tokens[$stackPtr]['level'] * $this->indent);

            if ($spaces !== $expected)
            {
                $error = 'Expected %s spaces before opening brace; %s found';
                $data  = [
                          $expected,
                          $spaces,
                         ];
                $fix   = $phpcsFile->addFixableError($error, $curlyBrace, 'SpaceBeforeBrace', $data);

                if ($fix === true)
                {
                    $indent = str_repeat(' ', $expected);

                    if ($spaces === 0)
                    {
                        $phpcsFile->fixer->addContentBefore($curlyBrace, $indent);
                    }
                    else
                    {
                        $phpcsFile->fixer->replaceToken(($curlyBrace - 1), $indent);
                    }
                }
            }
        }
    }
881658
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens    = $phpcsFile->getTokens();
        $prevToken = $phpcsFile->findPrevious(
            Tokens::$emptyTokens,
            ($stackPtr - 1),
            null,
            true
        );

        $expectedBlankLineCount = 1;
        $leadingLinePtr         = $this->getLeadingLinePointer($phpcsFile, $stackPtr, $prevToken);
        $blankLineCount         = ($tokens[$leadingLinePtr]['line'] - ($tokens[$prevToken]['line'] + 1));

        if (isset($tokens[$prevToken]['scope_opener']) === true && $tokens[$prevToken]['scope_opener'] === $prevToken) {
            $expectedBlankLineCount = 0;
        }

        if ($blankLineCount !== $expectedBlankLineCount) {
            $error = 'Expected %s blank line before return statement; %s found';
            $data  = array(
                      $expectedBlankLineCount,
                      $blankLineCount,
                     );
            $phpcsFile->addError($error, $stackPtr, 'BlankLineBeforeReturn', $data);
        }
    }
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);
        }
    }
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'
            );
        }
    }
587617
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens   = $phpcsFile->getTokens();
        $line     = $tokens[$stackPtr]['line'];

        while ($tokens[$stackPtr]['line'] == $line) {

            /*
             * Suffix interfaces with Interface;
             */
            if ('T_INTERFACE' === $tokens[$stackPtr]['type']) {
                $name = $phpcsFile->findNext(T_STRING, $stackPtr);

                if ($name && substr($tokens[$name]['content'], -9) !== 'Interface') {
                    $phpcsFile->addError(
                        'Interface name is not suffixed with "Interface"',
                        $stackPtr,
                        'InvalidInterfaceName'
                    );
                }
                break;
            }

            /*
             * Suffix traits with Trait;
             */
            if ('T_TRAIT' === $tokens[$stackPtr]['type']) {
                $name = $phpcsFile->findNext(T_STRING, $stackPtr);

                if ($name && substr($tokens[$name]['content'], -5) !== 'Trait') {
                    $phpcsFile->addError(
                        'Trait name is not suffixed with "Trait"',
                        $stackPtr,
                        'InvalidTraitName'
                    );
                }
                break;
            }

            /*
             * Suffix exceptions with Exception;
             */
            if ('T_EXTENDS' === $tokens[$stackPtr]['type']) {
                $extend = $phpcsFile->findNext(T_STRING, $stackPtr);

                if ($extend
                    && substr($tokens[$extend]['content'], -9) === 'Exception'
                ) {
                    $class = $phpcsFile->findPrevious(T_CLASS, $stackPtr);
                    $name = $phpcsFile->findNext(T_STRING, $class);

                    if ($name
                        && substr($tokens[$name]['content'], -9) !== 'Exception'
                    ) {
                        $phpcsFile->addError(
                            'Exception name is not suffixed with "Exception"',
                            $stackPtr,
                            'InvalidExceptionName'
                        );
                    }
                }
                break;
            }

            /*
             * Prefix abstract classes with Abstract.
             */
            if ('T_ABSTRACT' === $tokens[$stackPtr]['type']) {
                $name = $phpcsFile->findNext(T_STRING, $stackPtr);
                $function = $phpcsFile->findNext(T_FUNCTION, $stackPtr);
                
                if (false === $name) {
                    break;
                }

                // making sure we're not dealing with an abstract function
                if ((null === $function|| $name < $function)
                    && strpos($tokens[$name]['content'], 'Abstract') !== 0
                ) {
                    $phpcsFile->addError(
                        'Abstract class name is not prefixed with "Abstract"',
                        $stackPtr,
                        'InvalidAbstractName'
                    );
                }
                break;
            }

            $stackPtr++;
        }

        return;
    }
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');
		}
	}
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);
        }
    }
1329551
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {

        $tokens = $phpcsFile->getTokens();
        $forbidden = $this->get_forbidden_tokens();
        $token = $tokens[$stackPtr];
        $phpcsFile->addError($forbidden[$token['code']], $stackPtr, 'Found');
    }
1077896
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens    = $phpcsFile->getTokens();
		$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);

		if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS && $tokens[($stackPtr)]['code'] !== T_ECHO)
		{
			$error = '"%s" is a statement not a function; no parentheses are required';
			$data  = array($tokens[$stackPtr]['content']);
			$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data);

			if ($fix === true)
			{
				$end      = $phpcsFile->findEndOfStatement($nextToken);
				$ignore   = PHP_CodeSniffer_Tokens::$emptyTokens;
				$ignore[] = T_SEMICOLON;
				$closer   = $phpcsFile->findPrevious($ignore, ($end - 1), null, true);

				$phpcsFile->fixer->beginChangeset();
				$phpcsFile->fixer->replaceToken($nextToken, '');

				if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE)
				{
					$phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
				}

				if ($tokens[$closer]['code'] === T_CLOSE_PARENTHESIS)
				{
					$phpcsFile->fixer->replaceToken($closer, '');
				}

				$phpcsFile->fixer->addContent($stackPtr, ' ');
				$phpcsFile->fixer->endChangeset();
			}
		}

		if ($tokens[($stackPtr)]['code'] === T_ECHO
			&& $tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS
			&& $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE
		)
		{
			$error = 'There must be one space between the "%s" statement and the opening parenthesis';
			$data  = array($tokens[$stackPtr]['content']);
			$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterEcho', $data);

			if ($fix === true)
			{
				$this->requiredSpacesBeforeOpen = 1;
				$padding = str_repeat(' ', $this->requiredSpacesBeforeOpen);
				$phpcsFile->fixer->addContent($stackPtr, $padding);
			}
		}
	}
792263
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('5.4') === false) {
            return;
        }

        $tokens         = $phpcsFile->getTokens();
        $tokenContentLC = strtolower($tokens[$stackPtr]['content']);

        if ($tokenContentLC !== $tokens[$stackPtr]['content']) {
            $phpcsFile->addError(
                'The keyword \'%s\' was treated in a case-sensitive fashion in certain cases in PHP 5.4 or earlier. Use the lowercase version for consistent support.',
                $stackPtr,
                'NonLowercaseFound',
                array($tokenContentLC)
            );
        }
    }
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();
    }
887752
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.3') === false) {
            return;
        }

        $funcName = $phpcsFile->getDeclarationName($stackPtr);

        if (strtolower($funcName) !== 'assert') {
            return;
        }

        if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) {
            return;
        }

        if ($this->determineNamespace($phpcsFile, $stackPtr) === '') {
            // Not a namespaced function declaration. Parse error, but not our concern.
            return;
        }

        $phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found');
    }
640418
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $end = null;
        if (isset($tokens[$stackPtr]['scope_closer'])) {
            $end = $tokens[$stackPtr]['scope_closer'];
        }

        $scope = $phpcsFile->findNext(
            T_FUNCTION,
            $stackPtr,
            $end
        );

        $wantedTokens = array(
            T_PUBLIC,
            T_PROTECTED,
            T_PRIVATE
        );

        while ($scope) {
            $scope = $phpcsFile->findNext(
                $wantedTokens,
                $scope + 1,
                $end
            );

            if ($scope && $tokens[$scope + 2]['code'] === T_VARIABLE) {
                $phpcsFile->addError(
                    'Declare class properties before methods',
                    $scope,
                    'Invalid'
                );
            }
        }
    }