From 54f46bbdd9f9fc4b17bf0eb83bc118a273f84c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 9 Feb 2017 21:48:59 +0100 Subject: [PATCH] Be explicit about differences with PSR-7 --- README.md | 14 ++++++++------ src/Request.php | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0f5518a7..351c8d1e 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,16 @@ See the above usage example and the class outline for details. #### getHeaders() The `getHeaders(): array` method can be used to -return ALL headers. +return an array with ALL headers. -This will return an (possibly empty) assoc array with header names as -key and header values as value. The header value will be a string if -there's only a single value or an array of strings if this header has -multiple values. +The keys represent the header name in the exact case in which they were +originally specified. The values will be a string if there's only a single +value for the respective header name or an array of strings if this header +has multiple values. -Note that this differs from the PSR-7 implementation of this method. +> Note that this differs from the PSR-7 implementation of this method, +which always returns an array for each header name, even if it only has a +single value. #### getHeader() diff --git a/src/Request.php b/src/Request.php index af11fc91..ec2041d6 100644 --- a/src/Request.php +++ b/src/Request.php @@ -49,14 +49,16 @@ public function getHttpVersion() } /** - * Returns ALL headers + * Returns an array with ALL headers * - * This will return an (possibly empty) assoc array with header names as - * key and header values as value. The header value will be a string if - * there's only a single value or an array of strings if this header has - * multiple values. + * The keys represent the header name in the exact case in which they were + * originally specified. The values will be a string if there's only a single + * value for the respective header name or an array of strings if this header + * has multiple values. * - * Note that this differs from the PSR-7 implementation of this method. + * Note that this differs from the PSR-7 implementation of this method, + * which always returns an array for each header name, even if it only has a + * single value. * * @return array */ @@ -79,7 +81,7 @@ public function getHeader($name) foreach ($this->headers as $key => $value) { if (strtolower($key) === $name) { foreach((array)$value as $one) { - $found []= $one; + $found[] = $one; } } }