Gibt das Verzeichnis eines Namespaces in einem Verzeichnis zurück

dies nimmt einfach den Namespace
@return Dir absolute im angebenen $classPath oder relatives Verzeichnis
438703
public static function namespaceToPath($namespace, Dir $classPath = NULL) {
    // end und anfangs backslashs weg
    $namespace = trim($namespace,'\\'); 
    
    if (!isset($classPath)) {
      $classPath = new Dir('.'.DIRECTORY_SEPARATOR);
    }
    
    return $classPath->sub(str_replace('\\','/',$namespace).'/');
  }
1112566
private function namespaceMatches() : bool
    {
        $currentNamespace = ($this->currentNamespace && is_array($this->currentNamespace->name->parts))
            ? $this->currentNamespace->name->toString()
            : '';

        return $currentNamespace === $this->reflectedClass->getNamespaceName();
    }
18673
protected function findDeclaredFusionNamespaces()
    {
        $namespaces = [];

        $targetDirectory = $this->targetPackageData['path'] . '/Resources/Private';
        if(!is_dir($targetDirectory)) {
            return $namespaces;
        }

        foreach (Files::getRecursiveDirectoryGenerator($targetDirectory, null, true) as $pathAndFilename) {
            $pathInfo = pathinfo($pathAndFilename);
            if (!isset($pathInfo['filename'])) {
                continue;
            }
            if (strpos($pathAndFilename, 'Migrations/Code') !== false) {
                continue;
            }

            if (array_key_exists('extension', $pathInfo) && ($pathInfo['extension'] == 'ts2' || $pathInfo['extension'] == 'fusion')) {
                $namespaceDeclarationMatches = [];
                $count = preg_match_all(
                    '/^namespace:[\\s]*(?P<alias>[\\w\\.]+)[\\s]*\\=[\\s]*(?P<packageKey>[\\w\\.]+)[\\s]*$/um',
                    file_get_contents($pathAndFilename),
                    $namespaceDeclarationMatches,
                    PREG_SET_ORDER
                );
                if ($count > 0) {
                    foreach ($namespaceDeclarationMatches as $match) {
                        if (!array_key_exists($match['alias'], $namespaces)) {
                            $namespaces[$match['alias']] = $match['packageKey'];
                        } else {
                            if ($namespaces[$match['alias']] !== $match['packageKey']) {
                                $this->showWarning(
                                    sprintf(
                                        'Namespace-alias "%s" was declared multiple times for different aliases %s is used',
                                        $match['alias'],
                                        $namespaces[$match['alias']]
                                    )
                                );
                            }
                        }
                    }
                }
            }
        }
        return $namespaces;
    }
1029430
public function getBasePathList()
    {
        if (!isset($this->_pathList)) {
            $this->_pathList = [];
            $this->_namespaceList = [];
            $class = new ReflectionClass($this);
            while (true) {
                $dirname = dirname($class->getFileName());
                if ($dirname === __DIR__) break; // don't use this class
                
                $this->_pathList[] = $dirname;
                $this->_namespaceList[] = $class->getNamespaceName();

                $class = $class->getParentClass();

                if (empty($class)) break;
                if ($class->name == __CLASS__) break;

                // update module's dependencies

                if ($class->name != UniModule::className() && !in_array($class->name, $this->dependencies)) {
                    $this->dependencies[] = $class->name;
                }
            }
        }
        return $this->_pathList;
    }
1039530
public function rootPath()
    {
        return ('phar:' === substr($this->basePath, 0, 5)) ? dirname(str_replace('phar://', '', $this->basePath)) : $this->basePath;
    }
330427
private function getNamespaces()
    {
      $this->namespaces = array();

      $nodeList = $this->documentElement->getElementsByTagName('*');

      foreach($nodeList as $node)
      {
        if (strlen($node->prefix) && strlen($node->namespaceURI) && !in_array($node->prefix, $this->namespaces))
          $this->namespaces[$node->prefix] = $node->namespaceURI;
      }

      return $this->namespaces;
    }
174467
public function getNamespacedName() : ResolvedName {
        $namespaceDefinition = $this->getNamespaceDefinition();
        $content = $this->getFileContents();
        if ($namespaceDefinition === null) {
            // global namespace -> strip namespace\ prefix
            return ResolvedName::buildName($this->getNameParts(), $content);
        }

        if ($namespaceDefinition->name !== null) {
            $resolvedName = ResolvedName::buildName($namespaceDefinition->name->nameParts, $content);
        } else {
            $resolvedName = ResolvedName::buildName([], $content);
        }
        if (
            !($this instanceof QualifiedName && (
            ($this->parent instanceof NamespaceDefinition) ||
            ($this->parent instanceof NamespaceUseDeclaration) ||
            ($this->parent instanceof NamespaceUseClause) ||
            ($this->parent instanceof NamespaceUseGroupClause)))
        ) {
            $resolvedName->addNameParts($this->getNameParts(), $content);
        }
        return $resolvedName;
    }
1056914
public function getRelativePathToCurrentDirectoryParent()
    {
        if ($this->baseDir === $this->currentDir) {
            return DIRECTORY_SEPARATOR;
        }

        $path = realpath($this->currentDir . DIRECTORY_SEPARATOR . '..');

        return $this->getPathRelativeToBaseDir($path) ?: DIRECTORY_SEPARATOR;
    }
318188
protected function searchForNonNamespacedClass()
    {
        $filename = $this->_classFilename;

        foreach($this->_includePaths as $includePath)
        {
            $filePath = $includePath . DIRECTORY_SEPARATOR . $filename;

            if(file_exists($filePath) == true)
            {
                require($filename);

                return true;
            }
        }

        return false;
    }
545488
protected function getParentClasspath()
    {
        if ($this->getChild()->getAncestor()) {
            return $this->getChild()->getAncestor();
        } else {
            return $this->getObjectBuilder()->getClasspath();
        }
    }
18267
public function getClasspath()
    {
        if ($this->getPackage()) {
            $path = $this->getPackage() . '.' . $this->getClassname();
        } else {
            $path = $this->getClassname();
        }

        return $path;
    }
975109
public function createClasspath()
    {
        if ($this->isReference()) {
            throw $this->tooManyAttributes();
        }
        if ($this->classpath === null) {
            $this->classpath = new Path($this->project);
        }

        return $this->classpath->createPath();
    }
95220
public function applyNamespaceToPath($path)
    {
        /** @var ViewFinderInterface $finder */
        $finder = $this->getContainer()['view.finder'];
        if (!method_exists($finder, 'getHints')) {
            return $path;
        }
        $delimiter = $finder::HINT_PATH_DELIMITER;
        $hints = $finder->getHints();
        $view = array_reduce(array_keys($hints), function ($view, $namespace) use ($delimiter, $hints) {
            return str_replace($hints[$namespace], $namespace.$delimiter, $view);
        }, $path);
        return preg_replace("%{$delimiter}[\\/]*%", $delimiter, $view);
    }
928335
public function parent($numLevels = null)
    {
        if (null === $numLevels) {
            $numLevels = 1;
        }

        return $this->createPath(
            array_merge(
                $this->atoms(),
                array_fill(0, $numLevels, static::PARENT_ATOM)
            ),
            $this instanceof AbsolutePathInterface,
            false
        );
    }
319633
public function getRelativePath()
    {
        // Root module
        $parent = $this->module->getRelativePath();
        if (!$parent) {
            return $this->relativePath;
        }
        return Path::join($parent, $this->relativePath);
    }
216315
protected function searchForBackslashNamespacedClass()
    {
        $filename = $this->_classFilename;

        foreach($this->_includePaths as $includePath)
        {
            $className = str_replace('\\', '/', $filename);
            $filePath  = $includePath . DIRECTORY_SEPARATOR . $className;

            if(file_exists($filePath) == true)
            {
                require($filePath);

                return true;
            }
        }

        return false;
    }
524392
protected function retrieveNamespace()
    {
        if (! isset($this->syntaxTree[0]) || ! ($this->syntaxTree[0] instanceof Namespace_)) {
            throw new Exception("Could not locate namespace definition for class '".$this->classShortName."'");
        }

        $this->namespace = $this->syntaxTree[0];

        return $this;
    }