On Fri, Jul 28, 2017 at 11:59 AM, Craig Duncan <p...@duncanc.co.uk> wrote:

> Hi internals.
>
> As my initial thread about introducing warnings to the JSON functions was
> not immediately flooded with disagreement I took the liberty of creating an
> RFC for official discussion.
>
> The proposal is to have `json_encode()` and `json_decode()` raise warnings
> whenever a failure occurs, instead of requiring the developer to call
> `json_last_error()` each time.
>
> The functionality of `json_last_error()` and `json_last_error_msg()` are
> unaffected and they can still be used in exactly the same way they are
> today
>
> https://wiki.php.net/rfc/json_encode_decode_errors
>
>
I don't think this is a good idea. Especially in case of json_decode the
invalid JSON comes from sources that user does not have any control and
can't prevent the fail. Emitting warning wouldn't be helpful and it would
just make it more difficult to handle such cases.

Also it would break a big amount of code because in case of converting
errors to exceptions, you start getting a different exception so it would
have to be handled. I would call the whole proposal just a big BC break
(I'm aware that we don't consider adding warnings as BC but in this case it
is) for no benefit at all!

Cheers

Jakub

Reply via email to