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;
    }
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;
    }
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 ; }
Find all use statements.

@param PHP_CodeSniffer_File $file

@return array
Find all use statements .