Skip to content

Commit 846116e

Browse files
[HttpClient] revert bad logic around JSON_THROW_ON_ERROR
1 parent d90dd8d commit 846116e

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,7 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51
301301
}
302302

303303
try {
304-
if (\PHP_VERSION_ID >= 70300) {
305-
// Work around https://bugs.php.net/77997
306-
json_encode(null);
307-
$flags |= JSON_THROW_ON_ERROR;
308-
}
309-
310-
$value = json_encode($value, $flags, $maxDepth);
304+
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
311305
} catch (\JsonException $e) {
312306
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
313307
}

src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function toArray(bool $throw = true): array
148148
}
149149

150150
try {
151-
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
151+
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0));
152152
} catch (\JsonException $e) {
153153
throw new JsonException($e->getMessage(), $e->getCode());
154154
}

0 commit comments

Comments
 (0)