2017-07-27 17:41 GMT+02:00 Craig Duncan <p...@duncanc.co.uk>: > Hi internals, > > When using `json_encode()` and `json_decode()` it is required that you > manually check for errors after every call, eg: > > ```php > $data = json_decode("false"); > if (json_last_error() !== JSON_ERROR_NONE) { > throw new UnexpectedValueException(json_last_error_msg()); > } > ``` > > This isn't _that_ unusual in PHP, however normally in these situations a > warning would be raised. But the JSON functions only raise warnings in a > couple of scenarios, most issues are completely silent. > > I wanted to begin a discussion around changing this, so that warnings are > raised for any issues during `json_encode()` and `json_decode()`. > > I have an implementation ready and I'm happy to draft an RFC if this > suggestion doesn't receive universal hatred. >
It should rather just throw exceptions. Warnings do not really allow error handling, they just allow error reporting. Regards, Niklas