Skip to content

Commit

Permalink
Merge pull request #283 from guzzle/null-header-value
Browse files Browse the repository at this point in the history
Accept null and bool header values again
  • Loading branch information
sagikazarmark committed Jul 1, 2019
2 parents dc78403 + 95622d3 commit 239400d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/MessageTrait.php
Expand Up @@ -186,9 +186,9 @@ private function normalizeHeaderValue($value)
private function trimHeaderValues(array $values)
{
return array_map(function ($value) {
if (!is_string($value) && !is_numeric($value)) {
if (!is_scalar($value) && null !== $value) {
throw new \InvalidArgumentException(sprintf(
'Header value must be a string or numeric but %s provided.',
'Header value must be scalar or null but %s provided.',
is_object($value) ? get_class($value) : gettype($value)
));
}
Expand Down
3 changes: 1 addition & 2 deletions tests/ResponseTest.php
Expand Up @@ -263,8 +263,7 @@ public function invalidHeaderProvider()
return [
['foo', [], 'Header value can not be an empty array.'],
['', '', 'Header name can not be empty.'],
['foo', false, 'Header value must be a string or numeric but boolean provided'],
['foo', new \stdClass(), 'Header value must be a string or numeric but stdClass provided.'],
['foo', new \stdClass(), 'Header value must be scalar or null but stdClass provided.'],
];
}

Expand Down

0 comments on commit 239400d

Please sign in to comment.