Fix json_decode error return type#1235
Conversation
|
Please check this PR and let me know what you think: #993 Also the discussion 😊 |
|
Haha, reading what I just added in the description a second time, made it clear that json_decode can always return null/false even if that flag is set. |
f1bd8a4 to
a8d00e3
Compare
|
That other PR makes sense I guess, feels a bit specific to me maybe, but what it does not do, and what I want to actually see, is something even simpler. As stated also recently in another issue, the return type of Example test cases https://3v4l.org/CBHAi. But I'm not a JSON pro, maybe I'm missing something obvious.. |
|
this should not make ugly conflicts with the PR from Tomas (except potentially failing tests). Maybe we can add the return type behaviour that I described to his PR 🤔 or a follow-up might be even simpler |
|
Thank you! |
Looks like the previous code assumed that both
json_encodeandjson_decodedo not return false in case of an error andJSON_THROW_ON_ERRORis set. But actually, the error return value forjson_decodeisnull.https://www.php.net/manual/en/function.json-decode.php
Atm this does not change much, but I'd like to narrow down the return types there even more in 1.6, if possible.
Also: I guess I would have used a private constant, but went with the property for consistency.