: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$ihost[$position] = strtolower($ihost[$position]);
$this->scheme_normalization();
* Set the port. Returns true on success, false on failure (if there are
* any invalid characters).
public function set_port($port)
elseif (strspn($port, '0123456789') === strlen($port))
$this->port = (int) $port;
$this->scheme_normalization();
public function set_path($ipath, $clear_cache = false)
$ipath = (string) $ipath;
if (isset($cache[$ipath]))
$this->ipath = $cache[$ipath][(int) ($this->scheme !== null)];
$valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/');
$removed = $this->remove_dot_segments($valid);
$cache[$ipath] = array($valid, $removed);
$this->ipath = ($this->scheme !== null) ? $removed : $valid;
$this->scheme_normalization();
public function set_query($iquery)
$this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true);
$this->scheme_normalization();
* @param string $ifragment
public function set_fragment($ifragment)
$this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?');
$this->scheme_normalization();
* Convert an IRI to a URI (or parts thereof)
public function to_uri($string)
$non_ascii = implode('', range("\x80", "\xFF"));
$strlen = strlen($string);
while (($position += strcspn($string, $non_ascii, $position)) < $strlen)
$string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1);
public function get_iri()
if ($this->scheme !== null)
$iri .= $this->scheme . ':';
if (($iauthority = $this->get_iauthority()) !== null)
$iri .= '//' . $iauthority;
elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
$iri .= $this->normalization[$this->scheme]['ipath'];
if ($this->iquery !== null)
$iri .= '?' . $this->iquery;
if ($this->ifragment !== null)
$iri .= '#' . $this->ifragment;
public function get_uri()
return $this->to_uri($this->get_iri());
* Get the complete iauthority
protected function get_iauthority()
if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null)
if ($this->iuserinfo !== null)
$iauthority .= $this->iuserinfo . '@';
if ($this->ihost !== null)
$iauthority .= $this->ihost;
if ($this->port !== null && $this->port !== 0)
$iauthority .= ':' . $this->port;
* Get the complete authority
protected function get_authority()
$iauthority = $this->get_iauthority();
if (is_string($iauthority))
return $this->to_uri($iauthority);