diff --git a/src/Symfony/Component/HttpClient/CHANGELOG.md b/src/Symfony/Component/HttpClient/CHANGELOG.md index 7bd03aae382c8..95b6b10d88f2c 100644 --- a/src/Symfony/Component/HttpClient/CHANGELOG.md +++ b/src/Symfony/Component/HttpClient/CHANGELOG.md @@ -15,6 +15,7 @@ CHANGELOG * added `TraceableHttpClient`, `HttpClientDataCollector` and `HttpClientPass` to integrate with the web profiler * allow enabling buffering conditionally with a Closure * allow option "buffer" to be a stream resource + * allow arbitrary values for the "json" option 4.3.0 ----- diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index d691638b9f214..7cb82c73e5507 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -332,7 +332,7 @@ private static function normalizePeerFingerprint($fingerprint): array } /** - * @param array|\JsonSerializable $value + * @param mixed $value * * @throws InvalidArgumentException When the value cannot be json-encoded */ @@ -340,10 +340,6 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51 { $flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION); - if (!\is_array($value) && !$value instanceof \JsonSerializable) { - throw new InvalidArgumentException(sprintf('Option "json" must be array or JsonSerializable, %s given.', \is_object($value) ? \get_class($value) : \gettype($value))); - } - try { $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth); } catch (\JsonException $e) { diff --git a/src/Symfony/Component/HttpClient/HttpOptions.php b/src/Symfony/Component/HttpClient/HttpOptions.php index e2510d18411aa..1638189f6439b 100644 --- a/src/Symfony/Component/HttpClient/HttpOptions.php +++ b/src/Symfony/Component/HttpClient/HttpOptions.php @@ -86,7 +86,7 @@ public function setBody($body) } /** - * @param array|\JsonSerializable $json + * @param mixed $json * * @return $this */ diff --git a/src/Symfony/Contracts/HttpClient/HttpClientInterface.php b/src/Symfony/Contracts/HttpClient/HttpClientInterface.php index 2a89486d1bc71..68afa7811589b 100644 --- a/src/Symfony/Contracts/HttpClient/HttpClientInterface.php +++ b/src/Symfony/Contracts/HttpClient/HttpClientInterface.php @@ -33,11 +33,11 @@ interface HttpClientInterface 'query' => [], // string[] - associative array of query string values to merge with the request's URL 'headers' => [], // iterable|string[]|string[][] - headers names provided as keys or as part of values 'body' => '', // array|string|resource|\Traversable|\Closure - the callback SHOULD yield a string - // smaller than the amount requested as argument; the empty string signals EOF; when + // smaller than the amount requested as argument; the empty string signals EOF; if // an array is passed, it is meant as a form payload of field names and values - 'json' => null, // array|\JsonSerializable - when set, implementations MUST set the "body" option to - // the JSON-encoded value and set the "content-type" headers to a JSON-compatible - // value if they are not defined - typically "application/json" + 'json' => null, // mixed - if set, implementations MUST set the "body" option to the JSON-encoded + // value and set the "content-type" header to a JSON-compatible value if it is not + // explicitly defined in the headers option - typically "application/json" 'user_data' => null, // mixed - any extra data to attach to the request (scalar, callable, object...) that // MUST be available via $response->getInfo('user_data') - not used internally 'max_redirects' => 20, // int - the maximum number of redirects to follow; a value lower than or equal to 0 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy