You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve the signature of json_decode function #414
Since the safe implementation throws by default, the null value ia never returned. I thin we can improve the phpdoc return type of this function so that the return type is deduced depending on the value of $assoc parameter so that we can leverage better type checking using phpstan (https://phpstan.org/blog/phpstan-1-6-0-with-conditional-return-types)
JSON isn't just arrays and objects. null, 1, 1.25, true, false, "string" - are all valid JSON values, so the function may return null|int|float|bool|string|array|stdClass even in case of valid JSON
Activity
cedric-anne commentedon May 13, 2025
Actually
json_decodecan return a null value, if you decode thenullstring:[-]Improve the signature of json_decode function[/-][+]Improve the signature of `json_decode` function[/+]oprypkhantc commentedon May 28, 2025
JSON isn't just arrays and objects.
null,1,1.25,true,false,"string"- are all valid JSON values, so the function may returnnull|int|float|bool|string|array|stdClasseven in case of valid JSON