Skip to content

Commit 54f46bb

Browse files
committed
Be explicit about differences with PSR-7
1 parent 490775b commit 54f46bb

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ See the above usage example and the class outline for details.
4949
#### getHeaders()
5050

5151
The `getHeaders(): array` method can be used to
52-
return ALL headers.
52+
return an array with ALL headers.
5353

54-
This will return an (possibly empty) assoc array with header names as
55-
key and header values as value. The header value will be a string if
56-
there's only a single value or an array of strings if this header has
57-
multiple values.
54+
The keys represent the header name in the exact case in which they were
55+
originally specified. The values will be a string if there's only a single
56+
value for the respective header name or an array of strings if this header
57+
has multiple values.
5858

59-
Note that this differs from the PSR-7 implementation of this method.
59+
> Note that this differs from the PSR-7 implementation of this method,
60+
which always returns an array for each header name, even if it only has a
61+
single value.
6062

6163
#### getHeader()
6264

src/Request.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ public function getHttpVersion()
4949
}
5050

5151
/**
52-
* Returns ALL headers
52+
* Returns an array with ALL headers
5353
*
54-
* This will return an (possibly empty) assoc array with header names as
55-
* key and header values as value. The header value will be a string if
56-
* there's only a single value or an array of strings if this header has
57-
* multiple values.
54+
* The keys represent the header name in the exact case in which they were
55+
* originally specified. The values will be a string if there's only a single
56+
* value for the respective header name or an array of strings if this header
57+
* has multiple values.
5858
*
59-
* Note that this differs from the PSR-7 implementation of this method.
59+
* Note that this differs from the PSR-7 implementation of this method,
60+
* which always returns an array for each header name, even if it only has a
61+
* single value.
6062
*
6163
* @return array
6264
*/
@@ -79,7 +81,7 @@ public function getHeader($name)
7981
foreach ($this->headers as $key => $value) {
8082
if (strtolower($key) === $name) {
8183
foreach((array)$value as $one) {
82-
$found []= $one;
84+
$found[] = $one;
8385
}
8486
}
8587
}

0 commit comments

Comments
 (0)