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

Commit e396d37

Browse files
committed
Merge branch 'hotfix/319'
Close #319
2 parents 7561382 + 1b8ade5 commit e396d37

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ All notable changes to this project will be documented in this file, in reverse
2222

2323
### Fixed
2424

25-
- Nothing.
25+
- [#319](https://github.com/zendframework/zend-diactoros/pull/319) provides a fix to `Zend\Diactoros\Response` that ensures that the status
26+
code returned is _always_ an integer (and never a string containing an
27+
integer), thus ensuring it strictly adheres to the PSR-7 specification.
2628

2729
## 1.8.2 - 2018-07-19
2830

src/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,6 @@ private function setStatusCode($code)
186186
static::MAX_STATUS_CODE_VALUE
187187
));
188188
}
189-
$this->statusCode = $code;
189+
$this->statusCode = (int) $code;
190190
}
191191
}

test/ResponseTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ public function testCreateWithValidStatusCodes($code)
140140
{
141141
$response = $this->response->withStatus($code);
142142

143-
$this->assertSame($code, $response->getStatusCode());
143+
$result = $response->getStatusCode();
144+
145+
$this->assertSame((int) $code, $result);
146+
$this->assertInternalType('int', $result);
144147
}
145148

146149
public function validStatusCodes()
147150
{
148151
return [
149152
'minimum' => [100],
150153
'middle' => [300],
154+
'string-integer' => ['300'],
151155
'maximum' => [599],
152156
];
153157
}

0 commit comments

Comments
 (0)