Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60991 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98095 invoked from network); 27 Jun 2012 12:19:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2012 12:19:19 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.214.42 mail-bk0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:38711] helo=mail-bk0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/E5-02132-64AFAEF4 for ; Wed, 27 Jun 2012 08:19:19 -0400 Received: by bkcje2 with SMTP id je2so274038bkc.29 for ; Wed, 27 Jun 2012 05:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=g9OZwSwhOEsADeJhiLx32YkJi/bQtOkmDKWqqLn1Oz8=; b=MWrJDu8xTjpjT9TC3C835umeGpyrOrm+bqlDFEaZEmCv0RuCOF9kRaeCvZ/CT+jMiz kBTAqHC+KbRxlZI50KkyAZLHQpeOsVfra/gZGfK7cccpmdb2nWAizz28ibHFHfJYZ9Rw Xg9wFCsK6FqMWtCueNWcwGMjHT3CrCp/GibuVssTk9NOyO8UCHm9740JxNdlwDqsfrVg BRIU139eOXt6EVKKSvxGRHHoq3+4ESDGSCvg3nlbSsT6DHFVTKzYaNhwYUxx1MkG1UP5 u3lNm6bC67Brvd7ImFsgPZOp4IF04hJx/GZfyd/2mlJrd/bkTg1QNWrRzXIC5KA8ev6O 7lZg== MIME-Version: 1.0 Received: by 10.152.113.68 with SMTP id iw4mr20200130lab.50.1340799555849; Wed, 27 Jun 2012 05:19:15 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Wed, 27 Jun 2012 05:19:15 -0700 (PDT) In-Reply-To: References: <20120621141241.GA25789@analysisandsolutions.com> <4FE33EDF.2000409@lerdorf.com> <4FE61E9D.5050908@sugarcrm.com> <4FE734C4.2010706@lerdorf.com> <4FEA489D.1010601@sugarcrm.com> Date: Wed, 27 Jun 2012 14:19:15 +0200 Message-ID: To: Pierre Joye Cc: Benjamin Eberlei , Stas Malyshev , Rasmus Lerdorf , Gustavo Lopes , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: nikita.ppv@googlemail.com (Nikita Popov) On Wed, Jun 27, 2012 at 1:40 PM, Pierre Joye wrote: > hi, > > On Wed, Jun 27, 2012 at 1:30 PM, Nikita Popov wrote: > >>> Why not in the spirit of others have a new function json_last_error_msg() or >>> something similar? >> >> I implemented it with json_last_error(true) returning just a string, >> not an array. You can get the array using array(json_last_error(), >> json_last_error(true)) if you really want. But usually you will only >> need one of them as they both have different use cases. The >> stringified version for debugging and the error code version for >> detecting the error programmatically. > > I do not think this signature is consistent with the other error > functions. I'd to go with the _msg or _string equivalent. I looked at a few other error functions (of which we by the way we have *loads*, which is a bad sign) and indeed it seems that they all use a separate function to get the error message. Most use a xyz_errno() + xyz_error() pair. So it seems reasonable to instead provide the functionality via json_last_error_msg(). Any objections? Nikita