Skip to content

Commit 0a438b7

Browse files
authored
Merge pull request #6914 from kenjis/fix-phpdoc-Header
docs: fix PHPDoc in Header
2 parents cd7f3a6 + 062c984 commit 0a438b7

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

system/HTTP/Header.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ class Header
2828
/**
2929
* The value of the header. May have more than one
3030
* value. If so, will be an array of strings.
31+
* E.g.,
32+
* [
33+
* 'foo',
34+
* [
35+
* 'bar' => 'fizz',
36+
* ],
37+
* 'baz' => 'buzz',
38+
* ]
3139
*
32-
* @var array<array<string>|string>|string
40+
* @var array<int|string, array<string, string>|string>|string
3341
*/
3442
protected $value;
3543

3644
/**
3745
* Header constructor. name is mandatory, if a value is provided, it will be set.
3846
*
39-
* @param array<array<string>|string>|string|null $value
47+
* @param array<int|string, array<string, string>|string>|string|null $value
4048
*/
4149
public function __construct(string $name, $value = null)
4250
{
@@ -56,7 +64,7 @@ public function getName(): string
5664
* Gets the raw value of the header. This may return either a string
5765
* of an array, depending on whether the header has multiple values or not.
5866
*
59-
* @return array<array<string>|string>|string
67+
* @return array<int|string, array<string, string>|string>|string
6068
*/
6169
public function getValue()
6270
{
@@ -78,7 +86,7 @@ public function setName(string $name)
7886
/**
7987
* Sets the value of the header, overwriting any previous value(s).
8088
*
81-
* @param array<array<string>|string>|string|null $value
89+
* @param array<int|string, array<string, string>|string>|string|null $value
8290
*
8391
* @return $this
8492
*/
@@ -93,7 +101,7 @@ public function setValue($value = null)
93101
* Appends a value to the list of values for this header. If the
94102
* header is a single value string, it will be converted to an array.
95103
*
96-
* @param array<array<string>|string>|string|null $value
104+
* @param array<string, string>|string|null $value
97105
*
98106
* @return $this
99107
*/
@@ -118,7 +126,7 @@ public function appendValue($value = null)
118126
* Prepends a value to the list of values for this header. If the
119127
* header is a single value string, it will be converted to an array.
120128
*
121-
* @param array<array<string>|string>|string|null $value
129+
* @param array<string, string>|string|null $value
122130
*
123131
* @return $this
124132
*/

tests/system/HTTP/HeaderTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ public function testHeaderStoresArrayValues()
8080
$this->assertSame($value, $header->getValue());
8181
}
8282

83+
public function testHeaderStoresArrayKeyValue()
84+
{
85+
$name = 'foo';
86+
$value = [
87+
'key' => 'val',
88+
];
89+
90+
$header = new Header($name, $value);
91+
92+
$this->assertSame($name, $header->getName());
93+
$this->assertSame($value, $header->getValue());
94+
$this->assertSame('key=val', $header->getValueLine());
95+
}
96+
8397
public function testHeaderSetters()
8498
{
8599
$name = 'foo';

0 commit comments

Comments
 (0)