Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 6b3c333

Browse files
committed
Status code must be an integer following psr-7
1 parent 7561382 commit 6b3c333

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Response.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ public function withStatus($code, $reasonPhrase = '')
174174
*/
175175
private function setStatusCode($code)
176176
{
177-
if (! is_numeric($code)
178-
|| is_float($code)
177+
if (! is_int($code)
179178
|| $code < static::MIN_STATUS_CODE_VALUE
180179
|| $code > static::MAX_STATUS_CODE_VALUE
181180
) {

src/Response/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ private static function getStatusLine(StreamInterface $stream)
106106
throw new UnexpectedValueException('No status line detected');
107107
}
108108

109-
return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : ''];
109+
return [$matches['version'], (int) $matches['status'], isset($matches['reason']) ? $matches['reason'] : ''];
110110
}
111111
}

test/ResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function ianaCodesReasonPhrasesProvider()
7878
$records = $xpath->query('//ns:record');
7979

8080
foreach ($records as $record) {
81-
$value = $xpath->query('.//ns:value', $record)->item(0)->nodeValue;
81+
$value = (int) $xpath->query('.//ns:value', $record)->item(0)->nodeValue;
8282
$description = $xpath->query('.//ns:description', $record)->item(0)->nodeValue;
8383

8484
if (in_array($description, ['Unassigned', '(Unused)'])) {
@@ -185,6 +185,7 @@ public function invalidStatusCodes()
185185
'too-high' => [600],
186186
'null' => [null],
187187
'string' => ['foo'],
188+
'string-integer' => ['200'],
188189
];
189190
}
190191

0 commit comments

Comments
 (0)