Resolves "../" segments in a path.

"foo/bar/../baz" will return "foo/baz".

@param string $path

@return string
763316
public static function resolveUps($path)
    {
        $parts = array();
        foreach (explode('/', $path) as $part) {
            if ('..' === $part && count($parts) && '..' !== end($parts)) {
                array_pop($parts);
            } else {
                $parts[] = $part;
            }
        }

        return implode('/', $parts);
    }
1252945
protected function filterPath($path)
    {
        $path = preg_replace_callback(
            '/(?:[^' . self::CHARACTERS_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $path
        );

        if (empty($path)) {
            return $path;
        }

        if (substr($path, 0, 1) !== '/') {
            return $path;
        } else {
            return '/' . ltrim($path, '/');
        }
    }
1359537
public static function getPath(string $path): string {
		$e = explode("/", $path);
		unset($e[count($e) - 1]);

		return implode("/", $e);
	}
1071699
private function getPath($path)
    {
        return $this->root .
            ltrim(
                preg_replace(
                    sprintf('|%s{2,}|', preg_quote(DIRECTORY_SEPARATOR)),
                    DIRECTORY_SEPARATOR,
                    $path
                ),
                DIRECTORY_SEPARATOR
            );
    }
244622
private static function fixPath($path)
    {
        if (func_num_args() > 1) {
            return self::fixPath(implode('/', func_get_args()));
        }

        $replace = ['#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'];

        do {
            $path = preg_replace($replace, '/', $path, -1, $n);
        } while ($n > 0);

        return $path;
    }
884337
protected function _relpath($path) {
	
		
		$newpath = $path;
		
		
		if (substr($path, 0, 1) != '/') {
			$newpath = "/$newpath";
		}
		
		$newpath =  preg_replace("/\/$/", "", $newpath);
	
		$ret = ($newpath == $this->root) ? '' : substr($newpath, strlen($this->root)+1);
		
		return $ret;
	}
451357
public function normalize(?string $path): ?string
    {
        if ($this->preferredDirectorySeparator === $this->directorySeparator) {
            return $path;
        }

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

        return implode($this->preferredDirectorySeparator, explode($this->directorySeparator, $path));
    }
737527
private function normalizePipePath($path)
    {
        // Prepend slash if missing
        if (empty($path) || $path[0] !== '/') {
            $path = '/' . $path;
        }

        // Trim trailing slash if present
        if (strlen($path) > 1 && '/' === substr($path, -1)) {
            $path = rtrim($path, '/');
        }

        return $path;
    }
27883
public function getPrefixedPath(string $path = '') : string
  {
    return trim($this->parent ? 
      ($this->parent->getPrefixedPath($this->prefix ? $this->prefix . '/' . $path : $path)) :
      ($this->prefix ? $this->prefix . '/' . $path : $path), '/');
  }
768264
protected static function normalizePath($path)
    {
        if ('/' === substr($path, 0, 1)) {
            $path = static::removePathDotSegments($path);
        }

        $path = static::encodePath(
            static::decodeUrlEncodedChars(
                $path,
                '/[' . static::CHAR_UNRESERVED . ':@&=\+\$,\/;%]/'
            )
        );

        if (strlen($path) > 1 && '/' === substr($path, -1)) {
            $path = substr($path, 0, -1);
        }

        return $path;
    }
697129
public static function getParentPath($path)
    {
        if ($path === '/') {
            $parentPath = '';
        } elseif (strrpos($path, '/') === 0) {
            $parentPath = '/';
        } else {
            $parentPath = substr($path, 0, strrpos($path, '/'));
        }

        return $parentPath;
    }
1160430
private function parsePath($path)
    {
        if (empty($path)) {
            $path = Map::DEFAULT_URL_DELIMITER;
        }

        // get the clean path
        return $this->urlParser->parse($path);
    }
654344
public function pathToUrl($path) {
        if (empty($this->config['url_prefix'])) return '/'.$path;
        else if (empty($this->config['path'])) return rtrim($this->config['url_prefix'], '/').'/'.$path;
        else return rtrim($this->config['url_prefix'], '/').'/'.$this->relativePath($path);
    }
1219963
public function resolve (string $path) : string
    {
        if (1 === \preg_match('~^@(?<bundle>[^/]+)(?<rest>.*?)$~i', $path, $matches))
        {
            // We get a twig import path like `@Layout/test` and need to transform it to a symfony resource
            // location like `@LayoutBundle/Resources/views/test`.
            $rest = ltrim($matches["rest"], "/");

            return $this->kernel->locateResource(
                "@{$matches['bundle']}Bundle/Resources/views/{$rest}"
            );
        }

        return rtrim($this->twigDefaultPath, '/') . '/' . trim($path, '/');
    }
48939
public function Path($Path = NULL) {
      if (is_string($Path)) {
         $Result = $this->_ParsedRequestElement('Path', $Path);
      } else {
         $Result = $this->_ParsedRequestElement('Path');
         if ($Path === TRUE) {
            // Encode the path.
            $Parts = explode('/', $Result);
            $Parts = array_map('urlencode', $Parts);
            $Result = implode('/', $Parts);
         }
      }
      
      return $Result;
   }
366541
public function getPathParts($path)
    {
        $path = preg_replace('/\[/', '->[', $path);
        if (preg_match('/^->/', $path)) {
            $path = substr($path, 2);
        }

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

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

        return $path;
    }