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

@return bool
489867
protected function hasNotExpectedLength(File $phpCsFile, int $stackPointer): bool
    {
        $fileDockBlockTokens = $this->getFileDocBlockTokens($phpCsFile, $stackPointer);

        return (count($fileDockBlockTokens) !== static::EXPECTED_FILE_DOC_BLOCK_TOKEN_COUNT);
    }
440155
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens = $phpcsFile->getTokens();

        $memberCandidate    = $tokens[$stackPointer + 2];
        $semicolonCandidate = $tokens[$stackPointer + 3];
        $equalsCandidate    = $tokens[$stackPointer + 4];
        $valueCandidate     = $tokens[$stackPointer + 6];

        $isMemberVariable            = $memberCandidate['type'] === 'T_VARIABLE';
        $memberVariableWithSemicolon = $semicolonCandidate['type'] === 'T_SEMICOLON';
        $memberVariableWithEquals    = $equalsCandidate['type'] === 'T_EQUALS';
        $isValidValueType            = in_array($valueCandidate['type'], $this->validValueTypes, true);

        if ($isMemberVariable && $memberVariableWithSemicolon && !$memberVariableWithEquals && !$isValidValueType)
        {
            $type  = 'Production.MemberDefaultPresent.MembervariableWithoutDefaultValue';
            $data  = $memberCandidate['content'];
            $error = 'Membervariable ' . $memberCandidate['content'] . ' without default value';
            $phpcsFile->addWarning($error, $stackPointer, $type, $data);
        }
    }
447372
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->isFactory($phpCsFile, $stackPointer)) {
            return true;
        }

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

        return false;
    }
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'
            );
        }
    }
233242
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

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

        $scopeOpener = $tokens[$stackPtr]['scope_opener'];
        $scopeCloser = $tokens[$stackPtr]['scope_closer'];

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

        // Ignore if the next token is ELSE or ELSEIF, which means this is a IF/ELSEIF/ELSE block
        // Also, if it's a another closing bracket, this is OK, as we are closing a nesting of blocks
        if (in_array($tokens[$trailingContent]['code'], array(T_ELSE, T_ELSEIF, T_CLOSE_CURLY_BRACKET))) {
            return;
        }

        if ($tokens[$trailingContent]['line'] === ($tokens[$scopeCloser]['line'] + 1)) {
            $error = 'No blank line found after control structure';
            $phpcsFile->addError($error, $scopeCloser, 'NeedBlankLineAfterControlStruct');
        }
    }
301329
protected function isChainingMethod(File $phpCsFile, int $stackPointer): bool
    {
        $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);

        if (!$docBlockEndIndex) {
            return false;
        }

        $tokens = $phpCsFile->getTokens();

        $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];

        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
                continue;
            }
            if ($tokens[$i]['content'] !== '@return') {
                continue;
            }

            $classNameIndex = $i + 2;

            if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
                continue;
            }

            $content = $tokens[$classNameIndex]['content'];
            if (!$content) {
                continue;
            }

            return $content === '$this';
        }

        return false;
    }
1312372
protected function assertNoApiTag(File $phpCsFile, int $stackPointer): void
    {
        $apiIndex = $this->findApiAnnotationIndex($phpCsFile, $stackPointer);
        if (!$apiIndex) {
            return;
        }

        $fix = $phpCsFile->addFixableError('@api annotation is invalid.', $stackPointer, 'ApiAnnotationInvalid');

        if (!$fix) {
            return;
        }

        $tokens = $phpCsFile->getTokens();
        $line = $tokens[$apiIndex]['line'];

        $phpCsFile->fixer->beginChangeset();
        $phpCsFile->fixer->replaceToken($apiIndex, '');

        $index = $apiIndex;
        while ($tokens[$index - 1]['line'] === $line) {
            $index--;
            $phpCsFile->fixer->replaceToken($index, '');
        }
        $index = $apiIndex;
        while ($tokens[$index + 1]['line'] === $line) {
            $index++;
            $phpCsFile->fixer->replaceToken($index, '');
        }

        $phpCsFile->fixer->endChangeset();
    }
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);
    }
1183802
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.4') === false) {
            return;
        }

        // Get all parameters from function signature.
        $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
        if (empty($parameters) || \is_array($parameters) === false) {
            return;
        }

        foreach ($parameters as $param) {
            if (isset($this->superglobals[$param['name']]) === true) {
                $error     = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
                $errorCode = $this->stringToErrorCode(substr($param['name'], 1)) . 'Found';
                $data      = array($param['name']);

                $phpcsFile->addError($error, $param['token'], $errorCode, $data);
            }
        }
    }
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();
    }
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');
    }
1274814
protected function clearFileDocBlock(File $phpCsFile, int $stackPointer): void
    {
        $openTagIndex = $phpCsFile->findPrevious(T_OPEN_TAG, $stackPointer);

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

        $currentPosition = $fileDocBlockStartPosition;
        $endPosition = $phpCsFile->findNext([T_NAMESPACE], $currentPosition);
        while ($currentPosition < $endPosition) {
            $phpCsFile->fixer->replaceToken($currentPosition, '');
            $currentPosition++;
        }
    }
1068627
public function process(File $phpcsFile, $stackPtr)
    {
        $functionName   = $phpcsFile->getDeclarationName($stackPtr);
        $functionNameLc = strtolower($functionName);

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

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

        $itemInfo = array(
            'name'   => $functionName,
            'nameLc' => $functionNameLc,
        );
        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
    }
249742
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens       = $phpcsFile->getTokens();
        $currentToken = $tokens[$stackPointer];
        $prevToken    = $tokens[($stackPointer - 1)];
        $nextToken    = $tokens[($stackPointer + 1)];

        if ($prevToken['code'] !== T_WHITESPACE || $nextToken['code'] !== T_WHITESPACE)
        {
            $error = 'Concat operator must be surrounded by spaces. ';
            $phpcsFile->addError($error, $stackPointer, 'Production.ConcatenationSpacing.NoSpaceAroundConcat');
        }

        if (($prevToken['code'] === T_WHITESPACE && false !== strpos($prevToken['content'], '  '))
            || ($nextToken['code'] === T_WHITESPACE && false !== strpos($nextToken['content'], '  '))
        )
        {
            // Indents in multi-line concatenations must not throw warnings.
            if ($currentToken['code'] === T_STRING_CONCAT && $prevToken['code'] === T_WHITESPACE)
            {
                return;
            }

            $error = 'Concat operator should be surrounded by just one space';
            $phpcsFile->addWarning($error, $stackPointer, 'Production.ConcatenationSpacing.OnlyOneSpaceAroundConcat');
        }
    }
1269265
protected function isClosureStatic(File $phpcsFile, $stackPtr)
    {
        $tokens    = $phpcsFile->getTokens();
        $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);

        return ($prevToken !== false && $tokens[$prevToken]['code'] === \T_STATIC);
    }
127273
public function process(File $phpcsFile, $stackPointer)
    {
        $tokens  = $phpcsFile->getTokens();
        $message = '';

        switch ($tokens[$stackPointer]['type'])
        {
            case 'T_OPEN_CURLY_BRACKET':
                if ($this->hasTwoConsecutiveLinefeeds($tokens, $stackPointer + 1))
                {
                    $message = 'Empty Line found after opening curly brace in line: ' . $tokens[$stackPointer]['line'];
                }
                break;
            case 'T_CLOSE_CURLY_BRACKET':
                if ($this->hasTwoConsecutiveLinefeeds($tokens, $stackPointer - 2))
                {
                    $message = 'Empty Line found before closing curly brace in line: ' . $tokens[$stackPointer]['line'];
                }
                break;
            default:
                throw new UnexpectedValueException('Unexpected token type.', 1442416456);
        }

        if ($message !== '')
        {
            $type = 'Production.EmptyLinesParenthesis.EmptyLineFound';
            $data = $tokens[$stackPointer]['content'];
            $phpcsFile->addWarning($message, $stackPointer, $type, $data);
        }
    }
1255356
protected function getSnifferIsApplicable(File $phpCsFile, int $stackPointer): bool
    {
        if ($this->isFacade($phpCsFile, $stackPointer)) {
            return true;
        }

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

        return false;
    }