Parse Parameters from Path.

@param string $path
546989
protected function parsePath($path)
    {
        $uriParams = array();
        $uriParamsCount = preg_match_all("/(:[^\/]*)/", $path, $uriParams);
        $translateParams = array();

        foreach ($uriParams[0] as $rawParam) {
            $param = str_replace(':', '', $rawParam);
            $this->addParameter($param, 'uri', true);

            $translateParams[$rawParam] = '{'.$param.'}';
        }

        $this->uri = strtr($path, $translateParams);
    }
1177166
protected function parsePropertiesFile($path)
    {
        $props = array();

        if (file_exists($path)) {
            $f = fopen($path, "r");
            if ($f !== false) {
                while (!feof($f)) {
                    $line = fgets($f);
                    $r    = preg_match("/([\w.]+)\s+=\s+(.+)/", $line, $m);
                    if ($r !== false && count($m) == 3)
                        $props[$m[1]] = $m[2];
                }
                fclose($f);
            }
        }

        return $props;
    }
1182221
private function splitPath($path)
    {
        // init
        $textDelimiter = '\'';
        $pathDelimiter = '.';
        $result = array();

        // action
        $stringIsOpen = false;
        $currentChunk = '';
        for ($i = 0; $i < strlen($path); $i++) {
            $currentSymbol = $path[$i];

            if ($currentSymbol == $textDelimiter) {
                $stringIsOpen = !$stringIsOpen;
            }

            if ($currentSymbol == $pathDelimiter && !$stringIsOpen) {
                $result[count($result)] = $currentChunk;
                $currentChunk = '';
                continue;
            }
            $currentChunk .= $currentSymbol;
        }

        $result[count($result)] = $currentChunk;

        // return
        return $result;
    }
97586
private function detectParameters(string $path):array
    {
        $params = array();

        for ($i = 0; $i < strlen($path); $i++) {
            if ($path[$i] == "{") {
                $param = "";
                for (($p = $i + 1); $p < strlen($path); $p++) {
                    if ($path[$p] == "}") {
                        $p = strlen($path);
                        array_push($params, $param);
                    } else {
                        $param = $param.$path[$p];
                    }
                }
            }
        }
        return ($params);
    }
566975
public static function normalizePath($path)
    {
        if (is_string($path)) {
            return explode('.', $path);
        }

        if (!is_array($path)) {
            return [$path];
        }

        return $path;
    }
735960
protected function resolvePath($path)
    {
        $newPath  = [];
        foreach (explode('/', $path) as $pathPart) {
            if ('.' !== $pathPart) {
                if ('..' !== $pathPart) {
                    $newPath[] = $pathPart;
                } else {
                    array_pop($newPath);
                }
            }
        }

        return implode('/', $newPath);
    }
656641
private function parseFile(string $path): array
    {
        $json = json_decode(file_get_contents($path), true);
        $root = dirname($path);

        $namespaces = array_merge(
            iterator_to_array($this->parseNamespaces($json['autoload']['psr-4'] ?: [], $root)),
            iterator_to_array($this->parseNamespaces($json['autoload-dev']['psr-4'] ?: [], $root))
        );
        return $namespaces;
    }
1204376
private function getFilterParams($path)
    {
        if (!$path) {
            $path = "";
        }

        $parts = explode("/", $path);
        if ($path == "") {

        } elseif (count($parts) == 1) {
            $this->filterParameters['id'] = $parts[0];
        } else {
            foreach ($parts as $key => $part) {
                if (($key % 2) == 1) {
                    $this->filterParameters[$parts[$key - 1]] = urldecode($part);
                } else {
                    $this->filterParameters[$part] = "";
                }
            }
        }

        $this->filterParameters = array_merge($_GET, $this->filterParameters);
    }
1180311
public static function parse($path)
    {
        $path = explode(':', $path, 2);

        if (count($path) == 2)
        {
            if (head($path) == 'app')
            {
                $path = app_path(last($path));
            }
            elseif (head($path) == 'base')
            {
                $path = base_path(last($path));
            }
            elseif (head($path) == 'config')
            {
                $path = config_path(last($path));
            }
            elseif (head($path) == 'database')
            {
                $path = database_path(last($path));
            }
            elseif (head($path) == 'public')
            {
                $path = public_path(last($path));
            }
            elseif (head($path) == 'storage')
            {
                $path = storage_path(last($path));
            }
            else
            {
                $path = head($path);
            }
        }
        else
        {
            $path = head($path);
        }

        return $path;
    }
1304951
private function pathinfo(string $path): array
    {
        $pathinfo = pathinfo($path) + compact('path');
        $pathinfo['dirname'] = array_key_exists('dirname', $pathinfo) ?
                            $this->normalizeDirname($pathinfo['dirname']) :
                            '';

        return $pathinfo;
    }
1173086
private function normalizePath($path)
    {
        $path = rtrim($path, '/');

        if (empty($path) or '/' !== substr($path, 0, 1)) {
            $path = '/';
        }

        return $path;
    }
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;
    }
1017532
protected function split($path)
  {
    if (is_array($path)) {
      $parts = $path;
    } else {
      $parts = explode("/", $path);
    }
    return $parts;
  }
11365
protected function parsePath(string $path): array
    {
        $parts = explode(DIRECTORY_SEPARATOR, $path);

        $file = array_pop($parts);

        return [
            'root' => implode(DIRECTORY_SEPARATOR, $parts),
            'file' => $file,
        ];
    }
116702
public function parse($path)
    {
        $rawDocument = $this->loadDocument($path);
        list($rawMetadata, $rawContent) = $this->splitDocument($rawDocument);
        return $this->createDocument($rawDocument, $rawMetadata, $rawContent);
    }
1237446
public static function parse($path) {
        if (!file_exists($path)) {
            throw new \Exception("$path not found");
        }

        $src = file_get_contents($path);
        if (!$src) {
            throw new \Exception("could not read $path");
        }

        // first of all do we have any frontmatter in there?
        preg_match(self::$frontmatter_regex, $src, $matches);
        if (!empty($matches)) {
            // if we have an empty frontmatter, this will fail 
            // but we still want to act like there was something there
            if (!($frontmatter = json_decode(trim($matches[1]), true))) {
                $frontmatter = array();
            }
        } else {
            $frontmatter = false;
        }

        // remove any frontmatter
        $plain_src = preg_replace(self::$frontmatter_regex, "", $src);

        return array(
            'frontmatter' => $frontmatter,
            'content' => $plain_src
        );
    }
460652
private static function processUriParams(&$path, &$params) {
		// if the route path contains parameters like `:key`
		if (preg_match_all(static::REGEX_PATH_PARAMS, $path, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
			$previousMatchEnd = 0;
			$regexParts = [];

			// extract all parameter names and create a regex that matches URIs and captures the parameters' values
			foreach ($matches as $match) {
				// remember the boundaries of the full match (e.g. `:key`) in the subject
				$matchStart = $match[0][1];
				$matchEnd = $matchStart + strlen($match[0][0]);

				// keep the part between this one and the previous match and escape it for regex
				$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd, $matchStart - $previousMatchEnd));

				// save the current parameter's name
				$params[] = $match[1][0];

				// insert an expression that will match the parameter's value
				$regexParts[] = static::REGEX_PATH_SEGMENT;

				// remember the end index of the current match
				$previousMatchEnd = $matchEnd;
			}

			// keep the part after the last match and escape it for regex
			$regexParts[] = static::regexEscape(substr($path, $previousMatchEnd));

			// replace the parameterized URI with a regex that matches the parameters' values
			$path = implode('', $regexParts);
		}
		// if the route path is not parameterized
		else {
			// just escape the path for literal usage in regex
			$path = static::regexEscape($path);
		}
	}