diff --git a/src/Iri.php b/src/Iri.php index f5f451962..ac5ecbeb5 100644 --- a/src/Iri.php +++ b/src/Iri.php @@ -216,7 +216,7 @@ public function __get($name) { $return = null; } - if ($return === null && isset($this->normalization[$this->scheme][$name])) { + if ($return === null && isset($this->scheme, $this->normalization[$this->scheme][$name])) { return $this->normalization[$this->scheme][$name]; } else { @@ -671,27 +671,29 @@ protected function remove_iunreserved_percent_encoded($regex_match) { } protected function scheme_normalization() { - if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { - $this->iuserinfo = null; - } - if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { - $this->ihost = null; - } - if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { - $this->port = null; - } - if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { - $this->ipath = ''; + if (isset($this->scheme, $this->normalization[$this->scheme])) { + if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { + $this->iuserinfo = null; + } + if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { + $this->ihost = null; + } + if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { + $this->port = null; + } + if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { + $this->ipath = ''; + } + if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { + $this->iquery = null; + } + if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { + $this->ifragment = null; + } } if (isset($this->ihost) && empty($this->ipath)) { $this->ipath = '/'; } - if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { - $this->iquery = null; - } - if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { - $this->ifragment = null; - } } /** diff --git a/src/Response/Headers.php b/src/Response/Headers.php index 1500c6754..0b423e4f3 100644 --- a/src/Response/Headers.php +++ b/src/Response/Headers.php @@ -37,7 +37,7 @@ public function offsetGet($offset) { $offset = strtolower($offset); } - if (!isset($this->data[$offset])) { + if (!isset($offset, $this->data[$offset])) { return null; } diff --git a/src/Utility/CaseInsensitiveDictionary.php b/src/Utility/CaseInsensitiveDictionary.php index 9abbb7912..336804750 100644 --- a/src/Utility/CaseInsensitiveDictionary.php +++ b/src/Utility/CaseInsensitiveDictionary.php @@ -51,6 +51,10 @@ public function offsetExists($offset) { $offset = strtolower($offset); } + if ($offset === null) { + $offset = ''; + } + return isset($this->data[$offset]); } @@ -66,6 +70,10 @@ public function offsetGet($offset) { $offset = strtolower($offset); } + if ($offset === null) { + $offset = ''; + } + if (!isset($this->data[$offset])) { return null; } @@ -91,6 +99,10 @@ public function offsetSet($offset, $value) { $offset = strtolower($offset); } + if ($offset === null) { + $offset = ''; + } + $this->data[$offset] = $value; } @@ -105,6 +117,10 @@ public function offsetUnset($offset) { $offset = strtolower($offset); } + if ($offset === null) { + $offset = ''; + } + unset($this->data[$offset]); }