Re: [RFC] Raise warnings for json_encode() and json_decode() issues
| From: | Nikita Popov | Date: | Fri, 28 Jul 2017 11:07:35 +0000 |
| Subject: | Re: [RFC] Raise warnings for json_encode() and json_decode() issues | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100072@lists.php.net to get a copy of this message | ||
On Fri, Jul 28, 2017 at 12:59 PM, Craig Duncan <php@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 y
> cm%ñ/ýßCÆ™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
>
> Thanks,
> Craig
>
Operations that are expected to fail should never generate warnings. We
should not design functions such that their correct use requires the use of
the error suppression operator.
I certainly agree that the current situation is not good and that the json
functions really ought to be throwing exceptions, but adding a warning now
is only going to make this worse.
Nikita