|
|
|
@ -33,6 +33,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* It will be implicitly called when you use `foreach` to traverse the collection. |
|
|
|
|
* @return \ArrayIterator an iterator for traversing the headers in the collection. |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function getIterator() |
|
|
|
|
{ |
|
|
|
|
return new \ArrayIterator($this->_headers); |
|
|
|
@ -44,6 +45,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* It will be implicitly called when you use `count($collection)`. |
|
|
|
|
* @return int the number of headers in the collection. |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function count() |
|
|
|
|
{ |
|
|
|
|
return $this->getCount(); |
|
|
|
@ -53,6 +55,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* Returns the number of headers in the collection. |
|
|
|
|
* @return int the number of headers in the collection. |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function getCount() |
|
|
|
|
{ |
|
|
|
|
return count($this->_headers); |
|
|
|
@ -64,7 +67,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* @param mixed $default the value to return in case the named header does not exist |
|
|
|
|
* @param bool $first whether to only return the first header of the specified name. |
|
|
|
|
* If false, all headers of the specified name will be returned. |
|
|
|
|
* @return string|array the named header(s). If `$first` is true, a string will be returned; |
|
|
|
|
* @return string|array|null the named header(s). If `$first` is true, a string will be returned; |
|
|
|
|
* If `$first` is false, an array will be returned. |
|
|
|
|
*/ |
|
|
|
|
public function get($name, $default = null, $first = true) |
|
|
|
@ -189,6 +192,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* @param string $name the header name |
|
|
|
|
* @return bool whether the named header exists |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function offsetExists($name) |
|
|
|
|
{ |
|
|
|
|
return $this->has($name); |
|
|
|
@ -202,6 +206,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* @param string $name the header name |
|
|
|
|
* @return string the header value with the specified name, null if the named header does not exist. |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function offsetGet($name) |
|
|
|
|
{ |
|
|
|
|
return $this->get($name); |
|
|
|
@ -215,6 +220,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* @param string $name the header name |
|
|
|
|
* @param string $value the header value to be added |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function offsetSet($name, $value) |
|
|
|
|
{ |
|
|
|
|
$this->set($name, $value); |
|
|
|
@ -227,6 +233,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
|
|
|
|
* This is equivalent to [[remove()]]. |
|
|
|
|
* @param string $name the header name |
|
|
|
|
*/ |
|
|
|
|
#[\ReturnTypeWillChange] |
|
|
|
|
public function offsetUnset($name) |
|
|
|
|
{ |
|
|
|
|
$this->remove($name); |
|
|
|
|