From d973530916dd77250ff771e13505e3e020ffa358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Sat, 25 Nov 2023 16:38:41 +0100 Subject: [PATCH] Use Null Coalescing Assignment Operators --- src/Json.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Json.php b/src/Json.php index 4df2399..ea4b6d0 100644 --- a/src/Json.php +++ b/src/Json.php @@ -23,7 +23,7 @@ final class Json */ public static function decode(string $json, ?bool $forceArray = null): mixed { - $forceArray = $forceArray ?? false; + $forceArray ??= false; $flags = $forceArray ? JSON_OBJECT_AS_ARRAY : 0; try { @@ -66,7 +66,7 @@ public static function decodeFile(string $path, bool $forceArray = null): mixed */ public static function encode(mixed $data, ?int $options = null): string { - $options = $options ?? 0; + $options ??= 0; try { return json_encode($data, $options | self::ENCODE_DEFAULT | JSON_THROW_ON_ERROR); @@ -80,7 +80,7 @@ public static function encode(mixed $data, ?int $options = null): string */ public static function pretty(mixed $value, ?int $options = null): string { - $options = $options ?? 0; + $options ??= 0; return self::encode($value, $options | self::ENCODE_PRETTY); }