json_decode(): Passing null to parameter #1 ($json) of type string is deprecated
Cause:
PHP 8.1 doesn't accept passing null values to functions with specific value type like string in the case of the function json_decode (php.net)[https://www.php.net/manual/en/function.json-decode]
json_decode(
string $json,
?bool $associative = null,
int $depth = 512,
int $flags = 0
): mixed
Fix:
Added a condition that checks if $data is null and takes default preferences if true.
The exception:
Cause: PHP 8.1 doesn't accept passing
null
values to functions with specific value type likestring
in the case of the functionjson_decode
(php.net)[https://www.php.net/manual/en/function.json-decode]Fix: Added a condition that checks if
$data
is null and takes default preferences if true.