parseUseStatements example

$traitImports = [];

        foreach ($class->getTraits() as $trait) {
            if (
                ! $trait->hasMethod($method->getName())
                || $trait->getFileName() !== $method->getFileName()
            ) {
                continue;
            }

            $traitImports = array_merge($traitImports$this->phpParser->parseUseStatements($trait));
        }

        return array_merge($classImports$traitImports);
    }

    /** * Retrieves imports for properties. * * @return array<string, class-string> */
    private function getPropertyImports(ReflectionProperty $property)
    {
/** * Parses a class. * * @deprecated use parseUseStatements instead * * @param ReflectionClass $class A <code>ReflectionClass</code> object. * * @return array<string, class-string> A list with use statements in the form (Alias => FQN). */
    public function parseClass(ReflectionClass $class)
    {
        return $this->parseUseStatements($class);
    }

    /** * Parse a class or function for use statements. * * @param ReflectionClass|ReflectionFunction $reflection * * @psalm-return array<string, string> a list with use statements in the form (Alias => FQN). */
    public function parseUseStatements($reflection): array
    {
        
Home | Imprint | This part of the site doesn't use cookies.