RobTrehy / LaravelUserPreferences

A package for Laravel to store user preferences for your project
MIT License
2 stars 0 forks source link

fix: avoid passing null to json_decode PHP8.1 #8

Closed Reex11 closed 2 years ago

Reex11 commented 2 years ago

The exception:

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.

RobTrehy commented 2 years ago

Thanks for contributing, I'll merge this one now :)