Skip to content

Commit f51bca9

Browse files
committed
[HttpClient] allow arbitrary JSON values in requests
Allow arbitrary values in the "json" request option. Previously values were limitated to arrays and objects of type JsonSerializable. This doesn't account for scalar values and classes with public properties (which don't need to implement JsonSerializable), all of which are perfectly acceptable arguments to json_encode.
1 parent d35bbd8 commit f51bca9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

HttpClient/HttpClientInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ interface HttpClientInterface
3333
'query' => [], // string[] - associative array of query string values to merge with the request's URL
3434
'headers' => [], // iterable|string[]|string[][] - headers names provided as keys or as part of values
3535
'body' => '', // array|string|resource|\Traversable|\Closure - the callback SHOULD yield a string
36-
// smaller than the amount requested as argument; the empty string signals EOF; when
36+
// smaller than the amount requested as argument; the empty string signals EOF; if
3737
// an array is passed, it is meant as a form payload of field names and values
38-
'json' => null, // array|\JsonSerializable - when set, implementations MUST set the "body" option to
39-
// the JSON-encoded value and set the "content-type" headers to a JSON-compatible
40-
// value if they are not defined - typically "application/json"
38+
'json' => null, // mixed - if set, implementations MUST set the "body" option to the JSON-encoded
39+
// value and set the "content-type" header to a JSON-compatible value if it is not
40+
// explicitly defined in the headers option - typically "application/json"
4141
'user_data' => null, // mixed - any extra data to attach to the request (scalar, callable, object...) that
4242
// MUST be available via $response->getInfo('user_data') - not used internally
4343
'max_redirects' => 20, // int - the maximum number of redirects to follow; a value lower than or equal to 0

0 commit comments

Comments
 (0)