{@inheritdoc}
@return URLImmutable
344431
public function removeParameters(array $parameters = null)
  {
    if ($this->isLocked()) {
      return $this->getObj()->removeParameters($parameters)->setLocked();
    } else {
      return parent::removeParameters($parameters);
    }
  }
783931
protected function parseUrl($url)
    {
        if ($parsed = parse_url($url)) {
            return $this->addPassword($parsed);
        }

        // A second try for not file:// schemes which does support absolute
        // paths (like sqlite:///)

        // Cut the scheme by hand
        $parts = explode(':', $url, 2);

        if (count($parts) != 2 || strlen($parts[0]) > 24) {
            throw new InvalidArgumentException("Unparseable url $url");
        }

        // Now cheat parse_url by giving it a file url
        if (!$parsed = parse_url('file:'.$parts[1])) {
            throw new InvalidArgumentException("Unparseable url $url");
        }

        $parsed['scheme'] = $parts[0];

        return $this->addPassword($parsed);
    }
774184
final public function getDate(): ?\DateTimeImmutable
    {
        /** @var null|string $dateHeader */
        $dateHeader = $this->getHeaders()->get('date');
        if (null === $dateHeader) {
            return null;
        }

        $alteredValue = $dateHeader;
        $alteredValue = \str_replace(',', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/^[a-zA-Z]+ ?/', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/ +\(.*\)/', '', $alteredValue);
        $alteredValue = (string) \preg_replace('/\bUT\b/', 'UTC', $alteredValue);
        if (0 === \preg_match('/\d\d:\d\d:\d\d.* [\+\-]\d\d:?\d\d/', $alteredValue)) {
            $alteredValue .= ' +0000';
        }

        try {
            $date = new \DateTimeImmutable($alteredValue);
        } catch (\Throwable $ex) {
            throw new InvalidDateHeaderException(\sprintf('Invalid Date header found: "%s"', $dateHeader), 0, $ex);
        }

        return $date;
    }
1286089
private function getUrlFileSerializer()
    {
        if ($this->urlFileSerializer === null) {
            $this->urlFileSerializer = new UrlFileSerializer();
            $this->urlFileSerializer->setServiceLocator($this->getServiceLocator());
        }

        return $this->urlFileSerializer;
    }
1152120
public function getUriBuilder()
    {
        $uriBuilder = $this->resourceMapper->getControllerContext()->getUriBuilder();

        $uriBuilder->reset()->setFormat($this->format)->setCreateAbsoluteUri(true);

        return $uriBuilder;
    }
565786
public function getProviderId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->providerId) {
            return new Uri();
        }

        return $this->providerId;
    }
952373
public function editableRoute()
    {
        $link = $this->inputVal();
        if (empty($link)) {
            $link = $this->placeholder();
        }

        return $link;
    }
648192
public function toAbsoluteUrl(Url $root = null)
    {
        $root = $this->getRoot() ?: $root;
        if (!$root->isUrlAbsolute()) {
            throw new \InvalidArgumentException();
        }
        if (!$this->isUrlAbsolute()) {
            $this->setScheme($root->getScheme());
            $this->setHost($root->getHost());
            if (!$this->isPathAbsolute()) {
                $path = $root->getPath();
                $path = substr($path, 0, strrpos($path, '/') + 1);
                $this->setPath($path . $this->getPath());
            }
        }
        return $this;
    }
1229401
public function getUri()
    {
        $uri = parent::getUri();

        if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
            $query = parse_url($uri, PHP_URL_QUERY);
            $currentParameters = [];
            if ($query) {
                parse_str($query, $currentParameters);
            }

            $queryString = http_build_query(array_merge($currentParameters, $this->getValues()), '', '&');

            $pos = strpos($uri, '?');
            $base = false === $pos ? $uri : substr($uri, 0, $pos);
            $uri = rtrim($base.'?'.$queryString, '?');
        }

        return $uri;
    }
691647
private function formatEndpoint()
    {
        $url = '';

        if (empty($this->uri)) {
            $url = $this->config['url'];
        } elseif (str_contains($this->uri, ['http', 'https'])) {
            $url = $this->uri;
        } elseif ($this->config->has('url')) {
            $url = $this->config['url'] . $this->uri;
        }

        if (empty($url)) {
            throw new RuntimeException('Attempting to send a request before defining a URI endpoint.');
        }

        return $url;
    }
1339114
public function getNormalizedHttpUrl()
    {
        $parts = parse_url($this->httpUrl);

        $port = @$parts['port'];
        $scheme = $parts['scheme'];
        $host = $parts['host'];
        $path = @$parts['path'];

        $port or $port = ($scheme == 'https') ? '443' : '80';

        if (($scheme == 'https' && $port != '443')
            || ($scheme == 'http' && $port != '80')
        ) {
            $host = "$host:$port";
        }
        return "$scheme://$host$path";
    }
900779
public function getUrlGenerator()
    {
        if (isset($this->urlGenerator)) {
            return $this->urlGenerator;
        }

        // Check if an URL Generator resolver was set.
        else if (! isset(static::$urlGeneratorResolver)) {
            throw new RuntimeException("URL Generator resolver not set on Paginator.");
        }

        return $this->urlGenerator = call_user_func(static::$urlGeneratorResolver, $this);
    }
1123214
public function withHost(string $host): UriInterface
    {
        $instance = clone $this;
        $instance->host = $this->marshalHost($host);

        return $instance;
    }
705666
protected function compile()
    {
        // The URI should be considered literal except for keys and optional parts
        // Escape everything preg_quote would escape except for : ( ) < >
        $regex = preg_replace('#' . self::REGEX_ESCAPE . '#', '\\\\$0', $this->uri);

        if (strpos($regex, '(') !== false) {
            // Make optional parts of the URI non-capturing and optional
            $regex = str_replace(array('(', ')'), array('(?:', ')?'), $regex);
        }

        // Insert default regex for keys
        $regex = str_replace(array('<', '>'), array('(?P<', '>' . self::REGEX_SEGMENT . ')'), $regex);

        $search = $replace = array();
        foreach ($this->regex as $key => $value) {
            $search[] = "<$key>" . self::REGEX_SEGMENT;
            $replace[] = "<$key>$value";
        }

        // Replace the default regex with the user-specified regex
        return sprintf('#^%s$#', str_replace($search, $replace, $regex));
    }
946521
public function getUrl(): \Psr\Http\Message\UriInterface
    {
        if (!$this->url) {
            return new Uri();
        }

        return $this->url;
    }
1042525
public function getUpdatedByUserId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->updatedByUserId) {
            return new Uri();
        }

        return $this->updatedByUserId;
    }
935094
public function getReferrer(): ?UrlInterface
    {
        $referrerHeader = $this->getHeader('Referer');
        if ($referrerHeader === null) {
            return null;
        }

        return Url::tryParse($referrerHeader);
    }