src/ReflectionEngine.php
public static function parseFileNamespace($fileName, $namespaceName)
    {
        $topLevelNodes = self::parseFile($fileName);
        // namespaces can be only top-level nodes, so we can scan them directly
        foreach ($topLevelNodes as $topLevelNode) {
            if (!$topLevelNode instanceof Namespace_) {
                continue;
            }
            $topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
            if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) {
                return $topLevelNode;
            }
        }

        throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName");
    }
public static function parseFileNamespace($fileName, $namespaceName)
    {
        $topLevelNodes = self::parseFile($fileName);
        // namespaces can be only top-level nodes, so we can scan them directly
        foreach ($topLevelNodes as $topLevelNode) {
            if (!$topLevelNode instanceof Namespace_) {
                continue;
            }
            $topLevelNodeName = $topLevelNode->name ? $topLevelNode->name->toString() : '';
            if (ltrim($topLevelNodeName, '\\') === trim($namespaceName, '\\')) {
                return $topLevelNode;
            }
        }

        throw new ReflectionException("Namespace $namespaceName was not found in the file $fileName");
    }
public static function parseFileNamespace ( $ fileName , $ namespaceName ) { $ topLevelNodes = self :: parseFile ( $ fileName ) ; // namespaces can be only top-level nodes, so we can scan them directly foreach ( $ topLevelNodes as $ topLevelNode ) { if ( ! $ topLevelNode instanceof Namespace_ ) { continue ; } $ topLevelNodeName = $ topLevelNode -> name ? $ topLevelNode -> name -> toString ( ) : '' ; if ( ltrim ( $ topLevelNodeName , '\\' ) === trim ( $ namespaceName , '\\' ) ) { return $ topLevelNode ; } } throw new ReflectionException ( "Namespace $namespaceName was not found in the file $fileName" ) ; }
Parses a file namespace and returns an AST for it

@param string $fileName Name of the file
@param string $namespaceName Namespace name

@return Namespace_
@throws ReflectionException
Parses a file namespace and returns an AST for it