Checks a file.

@param \SplFileInfo $file A \SplFileInfo instance
@param Tokens $tokens Tokens collection
179605
public function check(\SplFileInfo $file, Tokens $tokens)
    {
        $classes = array_keys($tokens->findGivenKind(T_CLASS));
        $numClasses = count($classes);

        for ($i = 0; $i < $numClasses; ++$i) {
            $index = $classes[$i];

            // figure out where the classy starts
            $classStart = $tokens->getNextTokenOfKind($index, array('{'));

            // figure out where the classy ends
            $classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);

            $this->checkMethods($tokens, $classStart, $classEnd);
        }
    }
616679
public function requireFile($file)
    {
        if (PHP_EOL !== "\n" && strpos($file, 'phar://') !== 0) {
            $realPath = strtr(realpath($file), '\\', '/');
            if ($realPath !== $file) {
                trigger_error("File name ($realPath) case mismatch for .$file", E_USER_ERROR);
            }
        }
        /** @noinspection PhpIncludeInspection */
        require $file;
    }
517509
protected function checkFileExistence(/*# string */ $file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            throw new NotFoundException(
                Message::get(Message::DEFINITION_NOT_FOUND, $file),
                Message::DEFINITION_NOT_FOUND
            );
        }
    }
651436
public function filter(\SplFileInfo $file)
    {
        foreach ($this->filter as $filter) {
            if ($filter->filter($file)) {
                return true;
            }
        }
        return false;
    }
594470
public function filter(\SplFileInfo $file)
    {
        $content = file_get_contents($file);
        $result = preg_match_all('/class\s+([^\s|\{]+)[\s\{]/im', $content, $results, PREG_PATTERN_ORDER);
        unset($content);

        if (!$result) {
            return false;
        }

        if (count($results[0]) > 1) {
            return false;
        }

        return true;
    }
490547
protected function setCode(array $tokens, int $line = 0): void
    {
        $this->tokens = $tokens;
        $this->line = $line;
    }
434438
public function processFileClasses(array $classes, string $file)
    {
        foreach ($classes as $name => $class) {
            if (is_null($class['docblock'])) {
                $this->errors[] = [
                    'type' => 'class',
                    'file' => $file,
                    'class' => $name,
                    'line' => $class['line'],
                ];
            }
        }
    }
611596
function processFile($token, $file)
	{
		// Why not in one condition?
		// @see http://forum.nettephp.com/cs/viewtopic.php?pid=29556#p29556
		if (!$file instanceof FileUpload) {
			return false;
		}

		/* @var $validateCallback Callback */
		$validateCallback = MultipleFileUpload::$validateFileCallback;

		/* @var $isValid bool */
		$isValid = $validateCallback->invoke($file);

		if ($isValid) {
			MultipleFileUpload::getQueuesModel()
				->getQueue($token)
				->addFile($file);
		}
		return $isValid;
	}
1281858
protected function checkTag(File $phpcsFile, int $stackPtr): void
    {
        $tokens = $phpcsFile->getTokens();

        $followingWhitespace = (int)$phpcsFile->findNext(T_DOC_COMMENT_WHITESPACE, $stackPtr + 1, $stackPtr + 2);
        if (!$followingWhitespace || $tokens[$followingWhitespace]['line'] !== $tokens[$stackPtr]['line']) {
            return;
        }

        // Skip for file doc blocks
        $namespaceStatement = $this->getNamespaceStatement($phpcsFile);
        if (!$namespaceStatement || $stackPtr < $namespaceStatement['start']) {
            return;
        }

        $content = $tokens[$followingWhitespace]['content'];
        if (strpos($content, ' ') === false || $content === ' ') {
            return;
        }

        $fix = $phpcsFile->addFixableError('There should be no additional whitespace around doc block tag types.', $stackPtr, 'WhitespaceAroundTypes');
        if ($fix) {
            $phpcsFile->fixer->replaceToken($followingWhitespace, ' ');
        }
    }
873288
private function validate(FileSystem\File $file)
    {
        $filters = $this->buildFilters();
        foreach ($filters as $filter) {
            if (! $filter->validate($file)) return false;
        }

        return true;
    }
779719
public function filter(\SplFileInfo $file)
    {
        if (! $this->filter) {
            throw new \LogicException('No Filter has been set');
        }
        return ! $this->filter->filter($file);
    }
1311352
protected function typeHint(File $file, array $tokens, $functionIndex) {
		$parenthesisCloseTagIndex = $tokens[$functionIndex]['parenthesis_closer'];
		$scopeOpenTagIndex = $tokens[$functionIndex]['scope_opener'];

		$typehintIndex = $file->findNext(T_STRING, $parenthesisCloseTagIndex + 1, $scopeOpenTagIndex);
		if ($typehintIndex === false) {
			return 'mixed';
		}

		$returnType = $tokens[$typehintIndex]['content'];

		$nullableIndex = $file->findNext(T_NULLABLE, $parenthesisCloseTagIndex + 1, $typehintIndex);

		if ($nullableIndex) {
			$returnType .= '|null';
		}

		return $returnType;
	}
861820
protected function checkAnnotations(File $phpCsFile, int $stackPointer): void
    {
        $tokens = $phpCsFile->getTokens();

        $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
        if (!$docBlockEndIndex) {
            return;
        }
        $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
        if (!$docBlockStartIndex) {
            return;
        }

        $methodAnnotations = $this->getFixableMethodAnnotations($phpCsFile, $docBlockStartIndex, $docBlockEndIndex);
        if (!$methodAnnotations) {
            return;
        }

        foreach ($methodAnnotations as $methodAnnotation) {
            $fixable = $phpCsFile->addFixableError(
                sprintf('Interface must be used for %s annotation of %s', $methodAnnotation['method'], $methodAnnotation['class']),
                $methodAnnotation['index'],
                'Annotation.Interface.Invalid'
            );
            if (!$fixable) {
                continue;
            }

            $content = $methodAnnotation['interface'] . ' ' . $methodAnnotation['method'];

            $phpCsFile->fixer->beginChangeset();
            $phpCsFile->fixer->replaceToken($methodAnnotation['index'] + 2, $content);
            $phpCsFile->fixer->endChangeset();
        }
    }
1181091
public function analyze($tokens)
    {
        if (($valid = $this->grammar->analyze($tokens, $error)) === false) {
            $this->setError(
                __FILE__,
                __LINE__,
                $error['line'],
                $error['token'],
                $error['expected']
            );
        }

        return $valid;
    }
1095461
public function filter(\SplFileInfo $file)
    {
        if ($this->minsize !== null && $this->minsize > $file->getSize()) {
            return false;
        }
        if ($this->maxsize !== null && $this->maxsize < $file->getSize()) {
            return false;
        }

        return true;
    }
291207
protected function findUseStatements(File $file)
    {
        if (array_key_exists($file->getFilename(), static::$useCache)) {
            return static::$useCache[$file->getFilename()];
        }

        $tokens = $file->getTokens();
        $usePosition = $file->findNext(T_USE, 0);
        $useStatements = [];

        while ($usePosition !== false) {
            if ($this->shouldIgnoreUse($file, $usePosition)) {
                $usePosition = $file->findNext(T_USE, $usePosition + 1);
                continue;
            }

            $fullPath = '';
            $lastString = '';
            $alias = '';

            $useEnd = $file->findNext(
                [T_SEMICOLON, T_COMMA],
                $usePosition
            );
            $useFullPathEnd = $file->findNext(
                [T_SEMICOLON, T_COMMA, T_WHITESPACE],
                $usePosition + 2
            );

            $afterUse = $file->findNext(
                [T_STRING, T_NS_SEPARATOR],
                $usePosition
            );

            while ($afterUse !== false) {
                $fullPath .= $tokens[$afterUse]['content'];

                if ($tokens[$afterUse]['code'] == T_STRING) {
                    $lastString = $tokens[$afterUse]['content'];
                }

                $afterUse = $file->findNext(
                    [T_STRING, T_NS_SEPARATOR],
                    $afterUse + 1,
                    $useFullPathEnd
                );
            }

            if ($useFullPathEnd != $useEnd) {
                if ($tokens[$useFullPathEnd + 1]['code'] !== T_AS) {
                    continue;
                }

                if ($tokens[$useFullPathEnd + 3]['code'] === T_STRING) {
                    $alias = $tokens[$useFullPathEnd + 3]['content'];
                }
            } else {
                $alias = $lastString;
            }

            $useStatements[$fullPath] = $alias;

            $usePosition = $file->findNext(T_USE, $usePosition + 1);
        }

        static::$useCache[$file->getFilename()] = $useStatements;

        return $useStatements;
    }
508214
protected function isAllowFile(SplFileInfo $file)
    {
        return in_array(strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)), $this->allow_ext);
    }