@param \PHP_CodeSniffer\Files\File $phpCsFile

@return bool
546143
protected function isRuleApplicable(File $phpCsFile): bool
    {
        $className = $this->getClassName($phpCsFile);
        $hasCorrectSuffix = (substr($className, -18) === 'DependencyProvider');

        return $hasCorrectSuffix;
    }
1327423
protected function isConsole(File $phpCsFile, int $stackPointer): bool
    {
        return $this->extendsAbstract($phpCsFile, $stackPointer, 'Console');
    }
314775
protected function getSnifferIsApplicable(File $phpCsFile, int $stackPointer): bool
    {
        if ($this->isProvider($phpCsFile)) {
            return true;
        }

        if ($this->isCollectionType($phpCsFile, $stackPointer)) {
            return true;
        }

        if ($this->isFactory($phpCsFile, $stackPointer)) {
            return true;
        }

        if ($this->isPlugin($phpCsFile, $stackPointer)) {
            return true;
        }

        if ($this->isType($phpCsFile, $stackPointer)) {
            return true;
        }

        return false;
    }
453457
protected function hasMoreThenOneNewInMethod(File $phpCsFile, int $stackPointer): bool
    {
        $openPointer = $phpCsFile->findNext(T_OPEN_CURLY_BRACKET, $stackPointer);
        $closePointer = $phpCsFile->findNext(T_CLOSE_CURLY_BRACKET, $openPointer);

        $firstNewPosition = $phpCsFile->findNext(T_NEW, $openPointer, $closePointer);
        if ($firstNewPosition === false) {
            return false;
        }

        $secondNewPosition = $phpCsFile->findNext(T_NEW, $firstNewPosition + 1, $closePointer);

        return ($secondNewPosition !== false);
    }
173183
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens = $phpcsFile->getTokens();
        // We are only interested in the first token in a multi-line string.
        if ($tokens[$stackPointer]['code'] === $tokens[$stackPointer - 1]['code'])
        {
            return;
        }

        $workingString     = $tokens[$stackPointer]['content'];
        $nextTokenPosition = $stackPointer + 1;
        while ($tokens[$nextTokenPosition]['code'] === $tokens[$stackPointer]['code'])
        {
            $workingString .= $tokens[$nextTokenPosition]['content'];
            $nextTokenPosition++;
        }

        // Check if it's a double quoted string.
        // Also make sure it's not a part of a string started in a previous line.
        // If it is, then we have already checked it.
        if (strpos($workingString, '"') === false || $workingString[0] !== '"')
        {
            return;
        }

        // The use of variables in double quoted strings is not allowed.
        if ($tokens[$stackPointer]['code'] === T_DOUBLE_QUOTED_STRING)
        {
            $this->handleDoubleQuotedString($phpcsFile, $stackPointer, $workingString);
        }

        $this->handleSpecialChars($phpcsFile, $stackPointer, $workingString);
    }
455605
protected function isApiMethod(File $phpCsFile, int $docBlockStartIndex): bool
    {
        $tokens = $phpCsFile->getTokens();

        foreach ($tokens[$docBlockStartIndex]['comment_tags'] as $index) {
            if ($tokens[$index]['content'] === '@api') {
                return true;
            }
        }

        return false;
    }
1174494
protected function ifOrElseIf(File $phpcsFile, $stackPtr)
    {
        return $this->isScopeCondition($phpcsFile, $stackPtr, array(T_IF, T_ELSEIF));
    }
151134
protected function getCurrentClassName(File $phpCsFile): string
    {
        $fullClassName = parent::getClassName($phpCsFile);

        return substr($fullClassName, strrpos($fullClassName, '\\') + 1);
    }
822003
protected function hasNamespace(File $phpCsFile, int $stackPointer): bool
    {
        $namespacePosition = $phpCsFile->findPrevious(T_NAMESPACE, $stackPointer);
        if (!$namespacePosition) {
            return false;
        }

        return true;
    }
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);
    }
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;
    }
353318
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens  = $phpcsFile->getTokens();
        $openTag = $tokens[$stackPointer];

        if ($openTag['content'] === '<?' || $openTag['content'] === '<?=')
        {
            $error = 'Short PHP opening tag used; expected "<?php" but found "%s"';
            $data  = [$openTag['content']];
            $phpcsFile->addError($error, $stackPointer, 'Production.OpenPHPTag.Found', $data);
            $phpcsFile->recordMetric($stackPointer, 'PHP short open tag used', 'yes');
        }
        else
        {
            $phpcsFile->recordMetric($stackPointer, 'PHP short open tag used', 'no');
        }

        if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO)
        {
            $nextVar = $tokens[$phpcsFile->findNext(Tokens::$emptyTokens, ($stackPointer + 1), null, true)];
            $error   = 'Short PHP opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
            $data    = [
                $nextVar['content'],
                $openTag['content'],
                $nextVar['content'],
            ];
            $phpcsFile->addError($error, $stackPointer, 'Production.OpenPHPTag.EchoFound', $data);
        }
    }
987020
protected function existsFileDocBlock(File $phpCsFile, int $stackPointer): bool
    {
        $fileDocBlockStartPosition = $phpCsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPointer);

        return ($fileDocBlockStartPosition !== false);
    }
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);
    }
935264
public function process(File $phpcsFile, $stackPtr)
    {
        // Don't do anything if the warning has already been thrown or is not necessary.
        if ($this->examine === false) {
            return ($phpcsFile->numTokens + 1);
        }

        $phpcsVersion = PHPCSHelper::getVersion();

        // Don't do anything if the PHPCS version used is above the minimum recommended version.
        if (version_compare($phpcsVersion, $this->minRecommendedVersion, '>=')) {
            $this->examine = false;
            return ($phpcsFile->numTokens + 1);
        }

        if (version_compare($phpcsVersion, $this->minSupportedVersion, '<')) {
            $isError      = true;
            $message      = "IMPORTANT: Please be advised that the minimum PHP_CodeSniffer version the PHPCompatibility standard supports is %s. You are currently using PHP_CodeSniffer %s. Please upgrade your PHP_CodeSniffer installation. The recommended version of PHP_CodeSniffer for PHPCompatibility is %s or higher.";
            $errorCode    = 'Unsupported_' . $this->stringToErrorCode($this->minSupportedVersion);
            $replacements = array(
                $this->minSupportedVersion,
                $phpcsVersion,
                $this->minRecommendedVersion,
                $errorCode,
            );
        } else {
            $isError      = false;
            $message      = "IMPORTANT: Please be advised that for the most reliable PHPCompatibility results, PHP_CodeSniffer %s or higher should be used. Support for lower versions will be dropped in the foreseeable future. You are currently using PHP_CodeSniffer %s. Please upgrade your PHP_CodeSniffer installation to version %s or higher.";
            $errorCode    = 'BelowRecommended_' . $this->stringToErrorCode($this->minRecommendedVersion);
            $replacements = array(
                $this->minRecommendedVersion,
                $phpcsVersion,
                $this->minRecommendedVersion,
                $errorCode,
            );
        }

        /*
         * Figure out the report width to determine how long the delimiter lines should be.
         *
         * This is not an exact calculation as there are a number of unknowns at the time the
         * notice is thrown (whether there are other notices for the file, whether those are
         * warnings or errors, whether there are auto-fixable issues etc).
         *
         * In other words, this is just an approximation to get a reasonably stable and
         * readable message layout format.
         *
         * {@internal
         * PHPCS has had some changes as to how the messages display over the years.
         * Most significantly in 2.4.0 it was attempted to solve an issue with messages
         * containing new lines. Unfortunately, that solution is buggy.
         * An improved version has been pulled upstream and will hopefully make it
         * into PHPCS 3.3.1/3.4.0.
         *
         * Anyway, this means that instead of new lines, delimiter lines will be used to improved
         * the readability of the (long) message.
         *
         * Also, as of PHPCS 2.2.0, the report width when using the `-s` option is 8 wider than
         * it should be. A patch for that is included in the same upstream PR.
         *
         * If/when the upstream PR has been merged and the minimum supported/recommended version
         * of PHPCompatibility would go beyond that, the below code should be adjusted.}}
         */
        $reportWidth = PHPCSHelper::getCommandLineData($phpcsFile, 'reportWidth');
        $showSources = PHPCSHelper::getCommandLineData($phpcsFile, 'showSources');
        if ($showSources === true && version_compare($phpcsVersion, '2.3.0', '>=')) {
            $reportWidth += 6;
        }

        $messageWidth  = ($reportWidth - 15); // 15 is length of " # | WARNING | ".
        $delimiterLine = str_repeat('-', ($messageWidth));
        $disableNotice = 'To disable this notice, add --exclude=PHPCompatibility.Upgrade.LowPHPCS to your command or add <exclude name="PHPCompatibility.Upgrade.LowPHPCS.%s"/> to your custom ruleset. ';
        $thankYou      = 'Thank you for using PHPCompatibility!';

        $message .= ' ' . $delimiterLine;
        $message .= ' ' . $disableNotice;
        $message .= ' ' . $delimiterLine;
        $message .= ' ' . $thankYou;

        $this->addMessage($phpcsFile, $message, 0, $isError, $errorCode, $replacements);

        $this->examine = false;
    }
824242
protected function isCore(File $phpCsFile): bool
    {
        $namespace = $this->getNamespace($phpCsFile);

        $coreNamespaces = [
            static::NAMESPACE_SPRYKER,
            static::NAMESPACE_SPRYKER_SDK,
            static::NAMESPACE_SPRYKER_SHOP,
            static::NAMESPACE_SPRYKER_ECO,
        ];

        return in_array($namespace, $coreNamespaces, true);
    }
537303
protected function getClassNameWithNamespace(File $phpCsFile): ?string
    {
        try {
            $lastToken = TokenHelper::getLastTokenPointer($phpCsFile);
        } catch (EmptyFileException $e) {
            return null;
        }

        if (!NamespaceHelper::findCurrentNamespaceName($phpCsFile, $lastToken)) {
            return null;
        }

        return ClassHelper::getFullyQualifiedName(
            $phpCsFile,
            $phpCsFile->findPrevious(TokenHelper::$typeKeywordTokenCodes, $lastToken)
        );
    }