Parses a path into an array of segments.

@param string $path
@return array
@throws ValidationException
188042
public static function parseSegments($path)
    {
        if (empty($path)) {
            throw new ValidationException("Cannot parse empty path");
        }
        $segments = [];
        $index = 0;
        $segments[] = self::parseSegmentFromPath($path, $index);
        while ($index < strlen($path)) {
            self::parseLiteralFromPath('/', $path, $index);
            $segments[] = self::parseSegmentFromPath($path, $index);
        }
        return $segments;
    }
1195329
protected function parsePath($path = null)
    {
        $this->dirname   = '';
        $this->basename  = '';
        $this->extension = '';
        $this->filename  = '';

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

        $parts = pathinfo($path);

        if (isset($parts['dirname'])) {
            $this->dirname = rtrim($parts['dirname'], '/');
        }

        if (isset($parts['basename'])) {
            $this->basename = $parts['basename'];
        }

        if (isset($parts['extension'])) {
            $this->extension = $parts['extension'];
        }

        if (isset($parts['filename'])) {
            $this->filename = $parts['filename'];
        }

        return $this;
    }
538981
public function parse($path)
    {
        // Require the file, if it throws an exception, rethrow it
        try {
            $temp = require $path;
        } catch (Exception $exception) {
            throw new ParseException(
                array(
                    'message'   => 'PHP file threw an exception',
                    'exception' => $exception,
                )
            );
        }

        // If we have a callable, run it and expect an array back
        if (is_callable($temp)) {
            $temp = call_user_func($temp);
        }

        // Check for array, if its anything else, throw an exception
        if (!is_array($temp)) {
            throw new UnsupportedFormatException('PHP file does not return an array');
        }

        return $temp;
    }
56536
protected function parseFile($path)
    {
        $content = $this->filesystem->readFile($path);

        return $this->parseContent($content, $path);
    }
1174695
private function parsePath($path)
    {
        $parts = explode('/', trim($path, '/'));
        for ($i = 0; $i < 1; $i++) {
            // All paths must contain /{workspace_entityType}
            if (false === $this->issetNotEmpty($i, $parts)) {
                throw RestException::invalidEndpoint($path);
            }
        }
        $this->extractEntityType($parts);
        $this->extractIdentifier($parts);
        $this->extractRelationship($parts);
        return $this;
    }
752423
public function parse(string $path): ?ViewPath
    {
        $this->validatePath($path);

        //Cutting extra symbols (see Twig)
        $filename = preg_replace(
            '#/{2,}#',
            '/',
            str_replace('\\', '/', (string)$path)
        );

        $namespace = $this->defaultNamespace;
        if (strpos($filename, '.') === false) {
            //Force default extension
            $filename .= '.' . $this->extension;
        } elseif (!$this->match($filename)) {
            return null;
        }

        if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false) {
            list($namespace, $filename) = explode(LoaderInterface::NS_SEPARATOR, $filename);
        }

        //Twig like namespaces
        if (isset($filename[0]) && $filename[0] == '@') {
            $separator = strpos($filename, '/');
            if ($separator === false) {
                throw new PathException(sprintf('Malformed view path"%s" (expecting "@namespace/name").', $path));
            }

            $namespace = substr($filename, 1, $separator - 1);
            $filename = substr($filename, $separator + 1);
        }

        return new ViewPath(
            $namespace,
            $this->fetchName($filename),
            $filename
        );
    }
996081
public static function normalizePath($path) {
    $parts = [];
    $path = str_replace('\\', '/', $path);
    $path = preg_replace('/\/+/', '/', $path);
    $segments = explode('/', $path);
    foreach ($segments as $segment) {
      if ($segment != '.') {
        $test = array_pop($parts);
        if (is_null($test)) {
          $parts[] = $segment;
        }
        elseif ($segment == '..') {
          if ($test == '..') {
            $parts[] = $test;
          }
          if ($test == '..' || $test == '') {
            $parts[] = $segment;
          }
        }
        else {
          $parts[] = $test;
          $parts[] = $segment;
        }
      }
    }
    return implode('/', $parts);
  }
468953
public function items($path) {
		if($this->xpath === null)
			return array();
		$r = array();
		$nodes = $this->xpath->evaluate($path);
		foreach($nodes as $n)
			$r[] = new Node($n);
		return $r;
	}
811666
private function validatePath($path)
    {
        $last = strlen($path)-1;
        if ($path[$last] == '/') {
            $path = substr($path, 0, -1);
        }
        return $path;
    }
694772
public function parse($path)
    {
        $data = json_decode(file_get_contents($path), true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $error_message  = 'Syntax error';
            if (function_exists('json_last_error_msg')) {
                $error_message = json_last_error_msg();
            }
            
            throw new Exception($error_message);
        }
        return $data;
    }
988916
private function parseFile($path)
    {
        try {
            $classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
        } catch (ParseException $e) {
            throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
        }

        // empty file
        if (null === $classes) {
            return [];
        }

        // not an array
        if (!\is_array($classes)) {
            throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
        }

        return $classes;
    }
932996
public function parsePath($path)
    {
        $parts = explode('/', trim($path, '/'));

        $pathArray = [];
        if ($parts[0] == '.') {
            $pathArray = $this->currentPath;
            array_shift($parts);
        }

        foreach ($parts as $part) {
            if ($part == '..') {
                if (count($pathArray)) {
                    array_pop($pathArray);
                } else {
                    throw new Field\ConfigurationException("Invalid path. To many '..', can't move higher root.");
                }
            } else {
                $pathArray[] = $part;
            }
        }

        return $pathArray;
    }
1370445
private function parsePath($path)
    {
        $info = pathinfo($path);
        $basename = $info['basename'];
        $dirname = $info['dirname'];

        foreach ($this->sizes as $prefix => $paths) {
            if (strpos($basename, $prefix) !== 0) {
                continue;
            }

            foreach ($paths as $path => $transform) {
                $needle = $path === '' ? '' : substr($dirname, -strlen($path));

                if ($path === $needle) {
                    return [Utils\Helpers::joinPath($dirname, substr($basename, strlen($prefix))), $transform];
                }
            }
        }

        return false;
    }
720758
public static function normalizeRelativePath($path)
    {
        $path = str_replace('\\', '/', $path);
        $path = static::removeFunkyWhiteSpace($path);

        $parts = [];

        foreach (explode('/', $path) as $part) {
            switch ($part) {
                case '':
                case '.':
                break;

            case '..':
                if (empty($parts)) {
                    throw new LogicException(
                        'Path is outside of the defined root, path: [' . $path . ']'
                    );
                }
                array_pop($parts);
                break;

            default:
                $parts[] = $part;
                break;
            }
        }

        return implode('/', $parts);
    }
1143983
public function resolvePath($path)
    {
        if ($path[0] == '/') {
            throw new \InvalidArgumentException('Cannot resolve absolute path.');
        }

        $segments = $this->getPathSegments();
        if (!empty($segments)) {
            // Remove the last segment for relative paths.
            array_pop($segments);
        }
        $path = trim($path, '/');
        foreach (explode('/', trim($path, '/')) as $segment) {
            if ($segment == '.') {
                continue;
            }
            elseif ($segment == '..' && !empty($segments) && end($segments) != '..') {
                array_pop($segments);
            }
            else {
                $segments[] = $segment;
            }
        }

        return implode('/', $segments);
    }
1287948
public function parse($path)
	{
		$data = @parse_ini_file($path, true);

		if (!$data)
		{
			$error = error_get_last();

			throw new ParseException($error);
		}

		return $data;
	}
1021491
public function match(string $path): array
    {
        $path = $path === '/' ? $path : \rtrim($path, '/ ');

        if (!isset($this->routes[$path])) {
            return [self::NOT_FOUND, $path];
        }

        return [self::FOUND, $this->routes[$path]];
    }