Skip to content

Commit

Permalink
resolving tests errors - type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnpdlk committed Nov 28, 2018
1 parent 27f5f1e commit d0166ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ public function getBodyAsString(): string

return ob_get_clean();
}
/**
* @var string|int|null $contentLength
*/
$contentLength = $this->getHeader('Content-Length');
if (\is_int($contentLength) || ctype_digit($contentLength)) {
return stream_get_contents($body, $contentLength);
return stream_get_contents($body, (int)$contentLength);
}

return stream_get_contents($body);
Expand Down
3 changes: 2 additions & 1 deletion lib/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ public function getStatusText(): string
public function setStatus($status)
{
if (\is_int($status) || ctype_digit($status)) {
$statusCode = $status;
$statusCode = (int)$status;
$statusText = self::$statusCodes[$status] ?? 'Unknown';
} else {
list(
$statusCode,
$statusText
) = explode(' ', $status, 2);
$statusCode=(int)$statusCode;
}
if ($statusCode < 100 || $statusCode > 999) {
throw new \InvalidArgumentException('The HTTP status code must be exactly 3 digits');
Expand Down

0 comments on commit d0166ec

Please sign in to comment.