From 402c86ef6655b718fc41b2ee48343084c7cf2fec Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Sun, 21 Jul 2024 17:13:08 +0800 Subject: [PATCH] feat: Update JSON encoding to use JSON_THROW_ON_ERROR in Encrypter and ConfigurationUrlParser (#691) Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- src/ConfigurationUrlParser.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ConfigurationUrlParser.php b/src/ConfigurationUrlParser.php index 48e8b9b..60ac8e4 100644 --- a/src/ConfigurationUrlParser.php +++ b/src/ConfigurationUrlParser.php @@ -13,6 +13,7 @@ use Hyperf\Collection\Arr; use InvalidArgumentException; +use JsonException; class ConfigurationUrlParser { @@ -159,10 +160,9 @@ protected function parseStringsToNativeTypes(mixed $value): mixed return $value; } - $parsedValue = json_decode($value, true); - - if (json_last_error() === JSON_ERROR_NONE) { - return $parsedValue; + try { + return json_decode($value, true, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $e) { } return $value;