@param \PHP_CodeSniffer\Files\File $phpCsFile
@param array $tokens
@param int $stackPointer

@return bool
172656
protected function isMarkedDeprecatedInDocBlock(File $phpCsFile, array $tokens, int $stackPointer): bool
    {
        $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
        if (!$docBlockEndIndex) {
            return false;
        }
        $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
                continue;
            }
            if (!in_array($tokens[$i]['content'], ['@deprecated'])) {
                continue;
            }
            return true;
        }

        return false;
    }
349423
protected function isCustomFileDocBlock(File $phpCsFile, int $stackPointer, string $license): bool
    {
        $fileDockBlockTokens = $this->getFileDocBlockTokens($phpCsFile, $stackPointer);

        $comment = '';
        foreach ($fileDockBlockTokens as $fileDockBlockToken) {
            $comment .= $fileDockBlockToken['content'];
        }

        if (trim($comment) === trim($license)) {
            return true;
        }

        return false;
    }
779838
protected function findDocBlock(File $phpCsFile, int $stackPointer): ?int
    {
        $tokens = $phpCsFile->getTokens();

        $index = $phpCsFile->findPrevious(T_WHITESPACE, $stackPointer - 1, null, true);

        if ($tokens[$index]['type'] === 'T_DOC_COMMENT_CLOSE_TAG') {
            return $index;
        }

        return null;
    }
584775
protected function isController(File $phpCsFile, int $stackPointer): bool
    {
        return $this->extendsAbstract($phpCsFile, $stackPointer, 'AbstractController');
    }
489867
protected function hasNotExpectedLength(File $phpCsFile, int $stackPointer): bool
    {
        $fileDockBlockTokens = $this->getFileDocBlockTokens($phpCsFile, $stackPointer);

        return (count($fileDockBlockTokens) !== static::EXPECTED_FILE_DOC_BLOCK_TOKEN_COUNT);
    }
320807
public function process(File $phpcsFile, $stackPointer)
    {
        ini_set('display_errors', 1);
        error_reporting(E_ALL);
        $tokens  = $phpcsFile->getTokens();
        $content = $tokens[$stackPointer]['content'];
        if ($tokens[$stackPointer]['type'] !== 'T_STRING' || stripos($content, 'in_array') === false)
        {
            return;
        }

        $end                 = $tokens[$stackPointer + 1]['parenthesis_closer'];
        $length              = $end - $stackPointer + 1;
        $inArrayContext      = $phpcsFile->getTokensAsString($stackPointer, $length);
        $inArrayContextMatch = [];
        preg_match('/in_array\\(\\s*.+,\\s*.+,\\s*true\\s*\\)/sim', $inArrayContext, $inArrayContextMatch);
        if (empty($inArrayContextMatch))
        {
            $type  = 'Production.StrictInArray.non-strictArray';
            $data  = [$inArrayContext];
            $error = 'in_array needs to have the third parameter set to true.';
            $phpcsFile->addWarning($error, $stackPointer, $type, $data);
        }
    }
601915
protected function isFacadeNotInBridgeReturned(File $phpCsFile, int $stackPointer): bool
    {
        $tokens = $phpCsFile->getTokens();
        $returnPointer = (int)$phpCsFile->findNext(T_RETURN, $stackPointer);
        $endOfLinePointer = $phpCsFile->findEndOfStatement($returnPointer);

        $statementTokens = array_slice($tokens, $returnPointer, $endOfLinePointer - $returnPointer);
        $statement = $this->parseTokensContent($statementTokens);

        if (preg_match('/return \$container->getLocator\(\)->(.*?)\(\)->facade\(\)/', $statement)) {
            return true;
        }

        return false;
    }
1361353
protected function addFileDocBlock(File $phpCsFile, int $stackPointer): void
    {
        $phpCsFile->fixer->beginChangeset();

        $this->clearFileDocBlock($phpCsFile, $stackPointer);

        $tokens = $phpCsFile->getTokens();
        $line = $tokens[$stackPointer]['line'];
        $fileDocBlockStartPosition = $stackPointer;
        while ($tokens[$fileDocBlockStartPosition + 1]['line'] === $line) {
            $fileDocBlockStartPosition++;
        }

        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addContent($fileDocBlockStartPosition, '/**');
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addContent($fileDocBlockStartPosition, ' * ' . sprintf(static::EXPECTED_COMMENT_FIRST_LINE_STRING, static::YEAR));
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addContent($fileDocBlockStartPosition, ' * ' . static::EXPECTED_COMMENT_SECOND_LINE_STRING);
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addContent($fileDocBlockStartPosition, ' */');
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);

        $phpCsFile->fixer->endChangeset();
    }
351940
protected function checkTryToken(File $phpcsFile, int $stackPtr): void
    {
        $tokens = $phpcsFile->getTokens();

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

        $this->expectSingleSpaceAfter($phpcsFile, $stackPtr, 'try');
    }
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'
            );
        }
    }
906334
protected function checkCatchToken(File $phpcsFile, int $stackPtr): void
    {
        $tokens = $phpcsFile->getTokens();

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

        $this->expectSingleSpaceBefore($phpcsFile, $stackPtr, 'catch');
        $this->expectSingleSpaceAfter($phpcsFile, $stackPtr, 'catch');
    }
1326958
protected function isSprykerNamespace(File $phpCsFile, int $stackPointer): bool
    {
        $firstNamespaceTokenPosition = $phpCsFile->findNext(T_STRING, $stackPointer);
        if ($firstNamespaceTokenPosition) {
            $firstNamespaceString = $phpCsFile->getTokens()[$firstNamespaceTokenPosition]['content'];
            $secondNamespaceTokenPosition = $phpCsFile->findNext(T_STRING, $firstNamespaceTokenPosition + 1);

            if (!$secondNamespaceTokenPosition) {
                return false;
            }

            $secondNamespaceString = $phpCsFile->getTokens()[$secondNamespaceTokenPosition]['content'];
            $isSprykerClass = (in_array($firstNamespaceString, $this->sprykerNamespaces) && in_array($secondNamespaceString, $this->sprykerApplications));
            $isSprykerTestClass = in_array($firstNamespaceString, $this->sprykerTestNamespaces) && in_array($secondNamespaceString, $this->sprykerApplications);

            return ($isSprykerClass || $isSprykerTestClass);
        }

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

        // Make sure this is trailing whitespace.
        $line = $tokens[$stackPtr]['line'];
        if (($stackPtr < count($tokens) - 1)
            && $tokens[($stackPtr + 1)]['line'] === $line
        ) {
            return;
        }

        if (strpos($tokens[$stackPtr]['content'], "\n") > 0
            || strpos($tokens[$stackPtr]['content'], "\r") > 0
        ) {
            $warning = 'Please trim any trailing whitespace';
            $phpcsFile->addWarning($warning, $stackPtr, 'Invalid');
        }
    }
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);
    }
1170182
protected function checkFacade(File $phpCsFile, int $stackPointer): void
    {
        $name = $this->findClassOrInterfaceName($phpCsFile, $stackPointer);
        $facadeInterfaceFile = str_replace('Facade.php', 'FacadeInterface.php', $phpCsFile->getFilename());

        if (!file_exists($facadeInterfaceFile)) {
            $phpCsFile->addError('FacadeInterface missing for ' . $name, $stackPointer, 'InterfaceMissing');
        }
    }
1075397
protected function isPublicMethod(File $phpCsFile, int $stackPointer): bool
    {
        $publicPosition = $phpCsFile->findFirstOnLine(T_PUBLIC, $stackPointer);
        if ($publicPosition) {
            return true;
        }

        return false;
    }
321806
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens     = $phpcsFile->getTokens();
        $functionLc = strtolower($tokens[$stackPtr]['content']);
        if (isset($this->targetFunctions[$functionLc]) === false) {
            return;
        }

        // Next non-empty token should be the open parenthesis.
        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
        if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) {
            return;
        }

        $ignore = array(
            \T_DOUBLE_COLON    => true,
            \T_OBJECT_OPERATOR => true,
            \T_FUNCTION        => true,
            \T_NEW             => true,
        );

        $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
        if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) {
            // Not a call to a PHP function.
            return;
        } elseif ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING) {
            // Namespaced function.
            return;
        }

        $data = $tokens[$stackPtr]['content'];

        /*
         * Check for usage of the functions in the global scope.
         *
         * As PHPCS can not determine whether a file is included from within a function in
         * another file, so always throw a warning/error.
         */
        if ($phpcsFile->hasCondition($stackPtr, array(\T_FUNCTION, \T_CLOSURE)) === false) {
            $isError = false;
            $message = 'Use of %s() outside of a user-defined function is only supported if the file is included from within a user-defined function in another file prior to PHP 5.3.';

            if ($this->supportsAbove('5.3') === true) {
                $isError  = true;
                $message .= ' As of PHP 5.3, it is no longer supported at all.';
            }

            $this->addMessage($phpcsFile, $message, $stackPtr, $isError, 'OutsideFunctionScope', $data);
        }

        /*
         * Check for usage of the functions as a parameter in a function call.
         */
        if ($this->supportsBelow('5.2') === false) {
            return;
        }

        if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) {
            return;
        }

        $throwError = false;

        $closer = end($tokens[$stackPtr]['nested_parenthesis']);
        if (isset($tokens[$closer]['parenthesis_owner'])
            && $tokens[$tokens[$closer]['parenthesis_owner']]['type'] === 'T_CLOSURE'
        ) {
            $throwError = true;
        } else {
            $opener       = key($tokens[$stackPtr]['nested_parenthesis']);
            $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
            if ($tokens[$prevNonEmpty]['code'] !== \T_STRING) {
                return;
            }

            $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true);
            if ($tokens[$prevPrevNonEmpty]['code'] === \T_FUNCTION) {
                return;
            }

            $throwError = true;
        }

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

        $phpcsFile->addError(
            '%s() could not be used in parameter lists prior to PHP 5.3.',
            $stackPtr,
            'InParameterList',
            $data
        );
    }