Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55265 invoked from network); 29 Jul 2017 15:53:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2017 15:53:24 -0000 X-Host-Fingerprint: 95.148.131.182 unknown Received: from [95.148.131.182] ([95.148.131.182:7160] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/AE-40376-27FAC795 for ; Sat, 29 Jul 2017 11:53:22 -0400 Message-ID: To: internals@lists.php.net References: Date: Sat, 29 Jul 2017 16:53:18 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 95.148.131.182 Subject: Re: [PHP-DEV] json_encode() / json_decode() warnings From: ajf@ajf.me (Andrea Faulds) Hi everyone, Andrea Faulds wrote: > Craig Duncan wrote: >> On 27 July 2017 at 16:57, Niklas Keller wrote: >> >>> It should rather just throw exceptions. Warnings do not really allow >>> error >>> handling, they just allow error reporting. >>> >>> >> Agreed, but I can't see Exceptions passing the vote. Warnings can be >> silenced by those that don't care and converted to Exceptions by those >> that >> do >> > > Could we not simply make it a flag? e.g. > > $bar = json_encode($foo, JSON_THROW_EXCEPTIONS); > $baz = json_decode($bar, false, 512, JSON_THROW_EXCEPTIONS); > > That wouldn't break backwards-compatibility, but would still provide the > desired functionality. :) > I wrote a patch to add this flag: https://github.com/php/php-src/pull/2662 -- Andrea Faulds https://ajf.me/