Tries to find the root directory for a given repository path

@param   Binary      $svn        The SVN binary
@param   string      $path       The file system path
@return  string|null             NULL if the root cannot be found, the root path otherwise
338018
public static function findRepositoryRoot(Binary $svn, $path)
    {
        $hasSvnDir  = function($path) {
            $svnDir = $path.'/'.'.svn';
            return file_exists($svnDir) && is_dir($svnDir);
        };

        $pathWithSvnDir = FileSystem::bubble($path, $hasSvnDir);

        $root       = $pathWithSvnDir;
        $parentDir  = dirname($pathWithSvnDir);
        while ($hasSvnDir($parentDir) && strlen($root) > 1) {
            $root      = dirname($root);
            $parentDir = dirname($parentDir);
        }
        return $root;
    }
1024322
public function parsePath(?string $path = null): ?string
    {
        if ($path === null) {
            return null;
        }
        $path = \str_replace('%DOCUMENT_ROOT%', $this->documentRoot, $path);
        $path = \str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
        return $path;
    }
57245
public function findAsset($file_path)
    {
        $real_path = $this->findRealPath($file_path);
        if ($real_path) {
            return trim(FilesystemHelper::resolveRelatedPath($this->web_root_path, $real_path), '/');
        }
        return null;
    }
805941
public function getBundleIdByBaseDir($path)
    {
        $bundleId = null;
        foreach ($this->bundleInfos as $id => $data) {
            if (0 === strpos($path, $data['base_dir'])) {
                $bundleId = $id;
                break;
            }
        }

        return $bundleId;
    }
91518
static public function getRootUrl($path=null)
    {
        if ($path && strpos($path, 'http') === 0) {
            return $path;
        }
        
        $url = trim(static::getCommon('rootUrl'), '/');
        
        if (!$url) {
            $url = UriHelper::getRootUrl();
        } elseif (strpos($url, 'http') !== 0) {
            $url = UriHelper::getRootUrl() . '/' . $url;
        }
        
        if ($path) {
            $url .= '/' . trim($path, '/');
        }
        
        return $url;
    }
1120737
private function getRelativePath(ResourceNode $root, ResourceNode $node, $path = '')
    {
        if ($node->getParent() !== $root->getParent() && null !== $node->getParent()) {
            $path = $node->getParent()->getName().DIRECTORY_SEPARATOR.$path;
            $path = $this->getRelativePath($root, $node->getParent(), $path);
        }

        return $path;
    }
69483
public static function fetch($path, $root) {
      $_ = (array)$root;
      if (strpos($path,'.') === false) {
        return isset($_[$path]) ? $_[$path] : null;
      } else {
        list($frag,$rest) = explode('.', $path, 2);
        if ($rest) {
          return isset($_[$frag]) ? self::fetch($rest, $_[$frag]) : null;
        } elseif ($frag) {
          return (array)$_[$frag];
        } else {
          return null;
        }
      }
    }
676250
public static function getNamespaceByPath($path, $is_dir = true)
    {
        // when relational path.
        if ($path[0] !== '/')
            return null;
        
        $root_ns = '';
        $filepath = $path;
        foreach (self::$namespaces as $p => $ns) {
            if (strpos($path, $p) !== false) {
                $root_ns = $ns;
                $filepath = substr($path, strlen($p) + 1);
                break;
            }
        }

        $ns = $filepath ? explode(DS, $filepath) : [];
        if (! $is_dir)
            array_pop($ns);
        array_unshift($ns, $root_ns);

        return join('\\', $ns);
    }
52507
public function findAllFiles(DirectoryPath $path = null)
    {
        if (null === $path) {
            $path = new DirectoryPath();
        }

        $finder = new Finder();
        $searchPath = $path->prepend($this->gitService->getRepositoryPath());

        $finder->in($searchPath->toAbsoluteString(DIRECTORY_SEPARATOR));

        $filePaths = [];

        foreach ($finder->files() as $file) {
            /** @var SplFileInfo $file */
            $filePaths[] = FilePath::parse('/' . $file->getRelativePathname())->prepend($path);
        }

        return $filePaths;
    }
78298
private function findPackageVersion($path, $fallback = null)
    {
        if (file_exists("$path/.git")) {
            $cwd = getcwd();
            chdir($path);

            $output = [];
            $status = null;
            exec('git rev-parse HEAD 2>&1', $output, $status);

            chdir($cwd);

            if ($status == 0) {
                return isset($fallback) ? "$fallback ($output[0])" : $output[0];
            }
        }

        return $fallback;
    }
779836
protected function generateAbsolutePath(string $root, string $path): ?string
    {
        if (false !== $absolute = realpath($root.DIRECTORY_SEPARATOR.$path)) {
            return $absolute;
        }

        return null;
    }
1108658
private function getRelativePathForResourceIcon($absolutePath)
    {
        if (empty($absolutePath)) {
            return null;
        }
        $pathInfo = pathinfo($absolutePath);

        return $this->fs->makePathRelative($pathInfo['dirname'], $this->webDir).$pathInfo['basename'];
    }
216090
public function base_path($path = null)
    {
        return empty($path) ? $this->path : $this->path . $path;
    }
1237465
protected function getContent(string $path): ?vfsStreamContent
    {
        if (null === self::$root) {
            return null;
        }

        if (self::$root->getName() === $path) {
            return self::$root;
        }

        if ($this->isInRoot($path) && self::$root->hasChild($path) === true) {
            return self::$root->getChild($path);
        }

        return null;
    }
554953
protected function _findPath($path)
    {
        $path = $this->_unifyPath($path);
        $dirs = $this->_dirs;

        $file = null;

        foreach ($dirs as $dir) {
            if (is_readable(realpath($dir.DS.$path))) {
                $file = $dir.DS.$path;
                break;
            }
        }

        return $file;
    }
218476
public static function findInPath($filename, $path)
    {
        $asset_path = DirectoryHelper::slashDirname($path) . $filename;
        if (file_exists($asset_path)) {
            return self::buildWebPath($asset_path);
        }
        return null;
    }
726041
public static final function addRoot(string $package, string $path) {
    if (!empty($package) && !empty($path)) {
      $dirname = realpath(Path::replaceOSSeparator($path));
      if (is_dir($dirname)) {
        Lang::$root[$package] = $dirname;
      }
    }
    return null;
  }