@param string $root
@param string $path

@return string|null
358713
protected function generateAbsolutePath(string $root, string $path): ?string
    {
        if (false === mb_strpos($path, '..'.DIRECTORY_SEPARATOR) &&
            false === mb_strpos($path, DIRECTORY_SEPARATOR.'..') &&
            false !== file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path)
        ) {
            return $absolute;
        }

        return null;
    }
499503
protected function findRoot($root)
    {
        // Empty root will set the path to assets
        if (!$root) {
            throw new \InvalidArgumentException("Missing argument for root path");
        }

        // Substitute leading ./ with BASE_PATH
        if (strpos($root, './') === 0) {
            return BASE_PATH . substr($root, 1);
        }

        // Substitute leading ./ with parent of BASE_PATH, in case storage is outside of the webroot.
        if (strpos($root, '../') === 0) {
            return dirname(BASE_PATH) . substr($root, 2);
        }

        return $root;
    }
1308356
private function getCommands($root = null, $dir = null)
	{
		$root = $root ?: __DIR__;
		$dir  = $dir  ?: '';
		$cur  = $root . ((!empty($dir)) ? DS . $dir : '');

		// Get files from command directory to use in list
		$files = array_diff(scandir($cur), array('..', '.'));

		foreach ($files as $file)
		{
			if (is_file($cur . DS . $file) && strpos($file, '.php') !== false)
			{
				$namespace  = str_replace($root . DS, '', $cur . DS . $file);
				$namespace  = str_replace(DS, '\\', $namespace);
				$class      = str_replace('.php', '', $namespace);

				// Make sure a valid class exists
				if (class_exists(__NAMESPACE__ . '\\' . $class))
				{
					$reflection = new \ReflectionClass(__NAMESPACE__ . '\\' . $class);

					// Make sure it implements the Command Interface
					if ($reflection->implementsInterface(__NAMESPACE__ . '\CommandInterface'))
					{
						$comment = $reflection->getDocComment();

						// Check for help ignore flag
						if (!preg_match('/@museIgnoreHelp/', $comment))
						{
							$this->_commands[] = $class;
						}
					}
				}
			}
			else if (is_dir($cur . DS . $file))
			{
				$this->getCommands($root, ((!empty($dir)) ? $dir . DS : '') . $file);
			}
		}
	}
268943
private function rooted($path)
	{
		if (substr($path, 0, strlen(PATH_ROOT)) == PATH_ROOT)
		{
			$path = 'ROOT' . substr($path, strlen(PATH_ROOT));
		}
		return $path;
	}
596682
public function get($root, $path)
	{
		$url = $root . $path;

		$response = Http::get($url . $this->countryCode . $this->localLang);

		if (is_array($response)) {

			return $response;
		} else {

			return false;
		}
	}
810797
public function toAbsolutePath($path, $rootDir)
    {
        if (!is_string($path)) {
            return false;
        }

        if ($this->isRelativePath($path)) {
            return $rootDir . DIRECTORY_SEPARATOR . $path;
        }

        return $path;
    }
1207500
protected static function overlayPath($path)
    {
        $path = str_replace('\\', '/', $path);
        $hasOverlay = false;
        if (strpos($path, self::$rootPath) !== 0) {
            // Path is not below root path, ignore it
            return $path;
        }

        $newPath = ltrim(substr($path, strlen(self::$rootPath)), '/');
        foreach (self::$overlayPaths as $overlay => $replace) {
            if (strpos($newPath, $overlay) === 0) {
                $newPath = $replace . substr($newPath, strlen($overlay));
                $hasOverlay = true;
                break;
            }
        }
        return $hasOverlay ? $newPath : $path;
    }
234456
protected function getRootUrl($scheme, $root = null)
	{
		if (is_null($root))
		{
			if (is_null($this->cachedRoot))
			{
				$this->cachedRoot = $this->forcedRoot ?: $this->request->root();
			}

			$root = $this->cachedRoot;
		}

		$start = starts_with($root, 'http://') ? 'http://' : 'https://';

		return preg_replace('~'.$start.'~', $scheme, $root, 1);
	}
462471
public function setRootAndPath(Document $root, $path)
    {
        $this->getArchive()->set('root_and_path', array('root' => $root, 'path' => $path));

        foreach ($this->getAdd() as $key => $document) {
            $document->setRootAndPath($root, $path.'._add'.$key);
        }
    }
269953
protected function getNestedValue($root, $path)
    {
        $node = &$root;

        $segments = explode($this->separator, $path);

        $last = count($segments) - 1;

        for ($i = 0; $i <= $last; ++$i) {
            $node = @$this->getNode($node, $segments[$i]);

            if ($node === null) {
                return null;
            }

            if (!is_scalar($node)) {
                continue;
            }

            if ($i == $last) {
                return $node;
            }

            return null;
        }

        return null;
    }
339499
public function get($path)
    {
        // Make sure we have a file
        if (empty($path)) {
            return null;
        }

        // Generate file URL
        $url = $this->urlProvider->getUrlFromPath($path);

        // Validate file URL
        if (! filter_var($url, FILTER_VALIDATE_URL)) {
            return null;
        }

        return $url;
    }
1079407
private function locateUsingRootPlaceholder(string $path): ?string
    {
        if (0 !== mb_strpos($path, '@') || 1 !== preg_match('{^@(?<name>[^:]+):(?<path>.+)$}', $path, $match)) {
            return null;
        }

        if (isset($this->roots[$match['name']])) {
            return $this->generateAbsolutePath($this->roots[$match['name']], $match['path']);
        }

        throw new NotLoadableException(sprintf('Invalid root placeholder "@%s" for path "%s"',
            $match['name'], $match['path']));
    }
74615
public function getChild($path)
    {
        if (is_string($path)) {
            $path = explode('/', $path);
        }
        $remaining = array_splice($path, 1, count($path) - 1);

        foreach ($this->childItems as $childItem) {
            if ($childItem->getId() == $path[0]) {
                if (empty($remaining)) {
                    return $childItem;
                } elseif ($childItem instanceof ParentItem) {
                    return $childItem->getChild($remaining);
                } else {
                    return null;
                }
            }
        }

        return null;
    }
466551
static function load($root = NULL)
  {
    if ($root === NULL)
    {
      $root = realpath(dirname(__FILE__));
    }

    $files = array(
      'Compiler',
      'Error',
      'Helpers',
      'Lexer',
      'Nodes',
      'Parser',
      'Rewriter',
      'Scope',
      'SyntaxError',
      'Value',

      'yy/Base',  // load the base class first
      'yy/While', // For extends While

      'yy/Access',
      'yy/Arr',
      'yy/Assign',
      'yy/Block',
      'yy/Call',
      'yy/Class',
      'yy/Closure',
      'yy/Code',
      'yy/Comment',
      'yy/Existence',
      'yy/Extends',
      'yy/For',
      'yy/If',
      'yy/In',
      'yy/Index',
      'yy/Literal',
      'yy/Obj',
      'yy/Op',
      'yy/Param',
      'yy/Parens',
      'yy/Range',
      'yy/Return',
      'yy/Slice',
      'yy/Splat',
      'yy/Switch',
      'yy/Throw',
      'yy/Try',
      'yy/Value',
    );

    foreach ($files as $file)
    {
      require_once "$root/$file.php";
    }
  }
87538
static public function urlToPath($path)
    {
        $path = parse_url($path);
        return $path === null ? null : str_replace('/', DIRECTORY_SEPARATOR, $path['path']);
    }
458296
function &_extensions(&$root, $path = null, $create = false)
    {
        if (!isset($root)) {
            $root = $this->currentCert;
        }

        switch (true) {
            case !empty($path):
            case !is_array($root):
                break;
            case isset($root['tbsCertificate']):
                $path = 'tbsCertificate/extensions';
                break;
            case isset($root['tbsCertList']):
                $path = 'tbsCertList/crlExtensions';
                break;
            case isset($root['certificationRequestInfo']):
                $pth = 'certificationRequestInfo/attributes';
                $attributes = &$this->_subArray($root, $pth, $create);

                if (is_array($attributes)) {
                    foreach ($attributes as $key => $value) {
                        if ($value['type'] == 'pkcs-9-at-extensionRequest') {
                            $path = "$pth/$key/value/0";
                            break 2;
                        }
                    }
                    if ($create) {
                        $key = count($attributes);
                        $attributes[] = array('type' => 'pkcs-9-at-extensionRequest', 'value' => array());
                        $path = "$pth/$key/value/0";
                    }
                }
                break;
        }

        $extensions = &$this->_subArray($root, $path, $create);

        if (!is_array($extensions)) {
            $false = false;
            return $false;
        }

        return $extensions;
    }
1207388
public function url(string $path = null): string
    {
        return $path ? sv_url($path) : sv_url()->current();
    }