{@inheritdoc}

@param File $phpcsFile
@param int  $stackPointer

@return void
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);
        }
    }
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;
    }
698109
protected function checkUseForClass(File $phpcsFile, int $stackPtr): void
    {
        $this->checkExtends($phpcsFile, $stackPtr);
        $this->checkImplements($phpcsFile, $stackPtr);
    }
694410
protected function assertNewlineBefore(File $phpCsFile, int $stackPointer): void
    {
        $fileDocBlockStartPosition = $phpCsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPointer);

        $tokens = $phpCsFile->getTokens();

        $prevIndex = $phpCsFile->findPrevious(T_WHITESPACE, $fileDocBlockStartPosition - 1, 0, true);

        if ($tokens[$prevIndex]['line'] === $tokens[$fileDocBlockStartPosition]['line'] - 2) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Whitespace issue around file doc block', $stackPointer, 'FileDocBlockSpacing');
        if (!$fix) {
            return;
        }

        $phpCsFile->fixer->beginChangeset();

        if ($tokens[$prevIndex]['line'] > $tokens[$fileDocBlockStartPosition]['line'] - 2) {
            $phpCsFile->fixer->addNewline($prevIndex);
        } else {
            $index = $prevIndex;
            while ($index < $fileDocBlockStartPosition - 1) {
                $index++;
                $phpCsFile->fixer->replaceToken($index, '');
            }
        }

        $phpCsFile->fixer->endChangeset();
    }
225127
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens            = $phpcsFile->getTokens();
        $currentToken      = $tokens[$stackPointer];
        $currentValue      = $currentToken['content'];
        $currentLine       = $currentToken['line'];
        $regexValueIsOctal = preg_match('/^0[0-9]+$/', $currentValue);
        $isWithinMkDir     = $phpcsFile->findPrevious(T_STRING, $stackPointer, $stackPointer - 7, null, 'mkdir');

        if (!$regexValueIsOctal || $isWithinMkDir !== false)
        {
            return;
        }

        $type  = 'Production.OctalValuePresent.ValueEelementIsOctal';
        $data  = $currentValue;
        $error = 'Value element is octal in Line: ' . $currentLine;
        $phpcsFile->addError($error, $stackPointer, $type, $data);
    }
20087
protected function addNewDocBlock(File $phpCsFile, int $stackPointer): void
    {
        $fix = $phpCsFile->addFixableError('Missing Constants interface doc block.', $stackPointer, 'DocBlockMissing');
        if (!$fix) {
            return;
        }

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

        $docBlockStartPosition--;

        $phpCsFile->fixer->beginChangeset();
        $this->insertDocBlock($phpCsFile, $docBlockStartPosition);
        $phpCsFile->fixer->addNewline($docBlockStartPosition);
        $phpCsFile->fixer->endChangeset();
    }
830176
public function process(File $phpcsFile, $stackPtr)
    {
        parent::process($phpcsFile, $stackPtr);
        $this->processReturnAboveThrows($phpcsFile, $stackPtr);
    }
1057205
protected function isType(File $phpCsFile, int $stackPointer): bool
    {
        return $this->extendsAbstract($phpCsFile, $stackPointer, 'AbstractType');
    }
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;
    }
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');
    }
1202978
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
            // Probably an interface method.
            return;
        }

        $closeBrace  = $tokens[$stackPtr]['scope_closer'];
        $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true);

        // Special case for empty JS functions.
        if ($phpcsFile->tokenizerType === 'JS' && $prevContent === $tokens[$stackPtr]['scope_opener']) {
            // In this case, the opening and closing brace must be
            // right next to each other.
            if ($tokens[$stackPtr]['scope_closer'] !== ($tokens[$stackPtr]['scope_opener'] + 1)) {
                $error = 'The opening and closing braces of empty functions must be directly next to each other; e.g., function () {}';
                $fix   = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBetween');
                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $closeBrace; $i++) {
                        $phpcsFile->fixer->replaceToken($i, '');
                    }

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

            return;
        }

        $nestedFunction = false;
        if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
            || $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true
            || isset($tokens[$stackPtr]['nested_parenthesis']) === true
        ) {
            $nestedFunction = true;
        }

        $braceLine = $tokens[$closeBrace]['line'];
        $prevLine  = $tokens[$prevContent]['line'];
        $found     = ($braceLine - $prevLine - 1);

        $afterKeyword  = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
        $beforeKeyword = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
        if ($nestedFunction === true) {
            if ($found < 0) {
                $error = 'Closing brace of nested function must be on a new line';
                $fix   = $phpcsFile->addFixableError($error, $closeBrace, 'ContentBeforeClose');
                if ($fix === true) {
                    $phpcsFile->fixer->addNewlineBefore($closeBrace);
                }
            } else if ($found > $this->allowedNestedLines) {
                $error = 'Expected %s blank lines before closing brace of nested function; %s found';
                $data  = array(
                          $this->allowedNestedLines,
                          $found,
                         );
                $fix   = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeNestedClose', $data);

                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    $changeMade = false;
                    for ($i = ($prevContent + 1); $i < $closeBrace; $i++) {
                        // Try to maintain indentation.
                        if ($tokens[$i]['line'] === ($braceLine - 1)) {
                            break;
                        }

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

                    // Special case for when the last content contains the newline
                    // token as well, like with a comment.
                    if ($changeMade === false) {
                        $phpcsFile->fixer->replaceToken(($prevContent + 1), '');
                    }

                    $phpcsFile->fixer->endChangeset();
                }//end if
            }//end if
        } else {
            if ($found !== (int) $this->allowedLines) {
                if ($this->allowedLines === 1) {
                    $plural = '';
                } else {
                    $plural = 's';
                }

                $error = 'Expected %s blank line%s before closing function brace; %s found';
                $data  = array(
                          $this->allowedLines,
                          $plural,
                          $found,
                         );
                $fix   = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeClose', $data);

                if ($fix === true) {
                    if ($found > $this->allowedLines) {
                        $phpcsFile->fixer->beginChangeset();
                        for ($i = ($prevContent + 1); $i < ($closeBrace); $i++) {
                            $phpcsFile->fixer->replaceToken($i, '');
                        }

                        $phpcsFile->fixer->replaceToken(($closeBrace - 1), $phpcsFile->eolChar);
                        $phpcsFile->fixer->endChangeset();
                    } else {
                        $phpcsFile->fixer->addNewlineBefore($closeBrace);
                    }
                }
            }//end if
        }//end if

    }
1315541
protected function getSnifferIsApplicable(File $phpCsFile, int $stackPointer): bool
    {
        if ($this->isController($phpCsFile, $stackPointer)) {
            return true;
        }

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

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

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

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

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

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

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

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

        return false;
    }
1115067
protected function isSprykerApiClass(File $phpCsFile, int $stackPointer): bool
    {
        if (!$this->hasNamespace($phpCsFile, $stackPointer) || !$this->hasClassOrInterfaceName($phpCsFile, $stackPointer)) {
            return false;
        }

        $namespace = $this->getNamespace($phpCsFile, $stackPointer);
        $name = $this->getClassOrInterfaceName($phpCsFile, $stackPointer);

        if ($this->isFacade($namespace, $name)
            || $this->isClient($namespace, $name)
            || $this->isQueryContainer($namespace, $name)
            || $this->isPlugin($namespace, $name)
        ) {
            return true;
        }

        return false;
    }
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'
            );
        }
    }
163102
protected function checkConstantsInterface(File $phpCsFile, int $stackPointer): void
    {
        $docBlockEndIndex = $this->findDocBlock($phpCsFile, $stackPointer);

        if (!$docBlockEndIndex) {
            $this->addNewDocBlock($phpCsFile, $stackPointer);
            return;
        }

        $this->checkExistingDocBlock($phpCsFile, $docBlockEndIndex);
    }
1027724
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('7.2') === false) {
            return;
        }

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

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

        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->checkForScopes) !== false) {
            return;
        }

        if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') {
            return;
        }

        $phpcsFile->addWarning('Use of __autoload() function is deprecated since PHP 7.2', $stackPtr, 'Found');
    }
1327423
protected function isConsole(File $phpCsFile, int $stackPointer): bool
    {
        return $this->extendsAbstract($phpCsFile, $stackPointer, 'Console');
    }