Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118186 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72264 invoked from network); 4 Jul 2022 22:12:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Jul 2022 22:12:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4EF4B180539 for ; Mon, 4 Jul 2022 17:05:03 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 4 Jul 2022 17:05:02 -0700 (PDT) Received: by mail-oi1-f177.google.com with SMTP id u199so14564458oie.0 for ; Mon, 04 Jul 2022 17:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TD+zN14Xq1zwAbC82Tnz4UhHTn3K88sTHsF4L4QU29Y=; b=ou/P8LbCuXZhLlTht+N5CEyZyBOZCApeDLvVkww4VAl/O9HJWDZF8d05gSpHVMM2uA QQUC4ZimUySuSUmAPl12HYIiu3qaMNg3GJ1V2yzM9mhlw+xhX2pL6xCnynMDXWZbwdmN 9FtzYmiMciV1vpuabuWKnzzTACRGfziJgtFq/bB1F+cuJczAsMe3iaM1iHoX1+ZQcChm quKwdfo3B9F1Jk0rdmlKy184pO+eoCzhmZ5qHmxxIixv1YfA6fWc4KixNZ3Ni8WJAwsm F0QKS4qUNFsAa4alDA5FA6Kv35/PDUnIBWlaby3PXAlX5WY2wAZsK1HNBDJK3VNOLj0h Cevw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TD+zN14Xq1zwAbC82Tnz4UhHTn3K88sTHsF4L4QU29Y=; b=sjMjxSvJAAiWljilPGK96ysMgjse2vZKMXHrOeekQGstZc6ofdOtm/VTy3WgYpSr4p OLxMNnp552A+9JrsSE5XiBrJjRKSPMYgJKVNNhJNmRQPGn8/UD3Wrt59cy1UWaNHPme/ mLQH7g+9DXC7mmQQipjgh9JoIMrgcmEG31Z2OszpXu6pDaOiBGSc3B7lLrlmU39clcJj 5F3BrnDAdZq7lMd8VUgXt9ULjKNH8sxpKgFwWsSzRFMPsmTS5TstXm4SPfMKMjO4Yx7W bFNorQvcWDmHTP+gHfRXQ5bwOXTNwihfuW6xZTIieUPg51IemUjcz3XdMd4ZlauXOT0A XuFQ== X-Gm-Message-State: AJIora95vVI6eiSwVWnDiFIK8tLRIi3hPFuI21mcSA6zKiqMYmjEnwYq 5wUG0jWtGnthU8d0J8hHaxANCfQWyLHUEI9shv0= X-Google-Smtp-Source: AGRyM1s78E/Xkgh5zOy3DSQ97c2IyRtOTd3INasRioKBQTdHZQwTBPYBFw0GkPX1g9bilXZoY6uH0YTClAgLpMia25k= X-Received: by 2002:a05:6808:1a1c:b0:335:6440:8119 with SMTP id bk28-20020a0568081a1c00b0033564408119mr18198957oib.59.1656979502008; Mon, 04 Jul 2022 17:05:02 -0700 (PDT) MIME-Version: 1.0 References: <7d72b5c1-d19b-8734-57e0-f02c402b09c2@gmail.com> <64e73280-83aa-c60d-4c01-54a617c5468f@gmail.com> In-Reply-To: Date: Tue, 5 Jul 2022 01:04:25 +0100 Message-ID: To: Jakub Zelenka Cc: Timon de Groot , PHP internals Content-Type: multipart/alternative; boundary="0000000000009e0cb605e3039a2b" Subject: Re: [PHP-DEV] [RFC] Add json_encode indent parameter From: petercowburn@gmail.com (Peter Cowburn) --0000000000009e0cb605e3039a2b Content-Type: text/plain; charset="UTF-8" On Mon, 4 Jul 2022 at 11:11, Jakub Zelenka wrote: > On Mon, Jul 4, 2022 at 8:38 AM Timon de Groot > wrote: > > > Hi internals, > > > > If the rest also thinks the RFC is good to go, I suggest we start a vote > > coming week. > > As this is my first RFC, I'm not so sure how this typically gets kicked > > off, so I'd like to know what I need to do! > > > > You just need to change status in RFC to Voting and in voting section set > the date range and add doodle poll - you can basically copy it from one of > the open RFC's (see for example code in > https://wiki.php.net/rfc/fetch_property_in_const_expressions ). Then you > just need to send email to internals with subject prefixed with [RFC][VOTE] > or similar. As noted you need to do it today or latest tomorrow. Feel free > to let me know if you are too busy or something is not clear. > > I would recommend not to do any last time changes as in such case you > should probably give an extra time for dicusion which means it won't make > the feature freeze and will have to wait for another year. In my opinion it > is good as it is. The tabs can be later added as an extra flag. If the flag > is set, we could just change default value for indent to 1 and use tabs but > it would be still possible for users to set indent size if they wish. I > think that's something that makes most sense to me and doesn't impact the > current RFC in any way. > > Regards > > Jakub > My thoughts might be firmly in the realms of "too little, too late" since the vote is open already, so by all means choose to ignore. Things that I would have liked to have seen in the RFC document: * the mention/consideration of a user-specified indent string (even if under a "Rejected Features" section with some details about the rejection) * details on the new parameter's interaction with / dependency on JSON_PRETTY_PRINT. * related, details on what happens when the new parameter is used without JSON_PRETTY_PRINT. (I'd personally like to have JSON_PRETTY_PRINT be implicitly added if the new parameter is used, or it could raise an error, or it could be ignored as seems to be the case but isn't explicltly mentioned) * details on allowed values of the new parameter, e.g. what happens with negative, or stupidly huge, values? * some summary (more than none!) of discussion topics / design decisions resulting from the mailing list thread(s) The RFC currently states (the quote is two-thirds of the proposal text, minus examples): > By default, an indentation of 4 spaces will be applied, just like the original json_encode behaviour with the JSON_PRETTY_PRINT option. > > When the indent parameter is passed a different value, an indentation of N spaces will be applied. Even after several readings of the proposal, I thought that you were proposing that json_encode() always be pretty-printed and indented. Even the examples weren't particularly helpful in correcting that mis-reading. It took me far too long to understand (hopefully correctly) that: * "By default..." means "When the flags include JSON_PRETTY_PRINT and the indent parameter is not passed (or 4 is passed)...". * "When the indent parameter is passed..." really means "When the flags include JSON_PRETTY_PRINT and the indent parameter is passed...". * Any calls to json_encode() without JSON_PRETTY_PRINT, with or without the indent parameter, behave identically to now. The "Unaffected PHP Functionality" section only muddied the waters further: "Normal usage ... of the json_encode function will not be affected, as the default of 4 spaces will still be in effect." My point being, I don't think this document was anywhere near ready... but feel free to disagree. Just to finish up, wouldn't it be nice to have the following?.. json_encode($value, indent: 2) Regards, Peter --0000000000009e0cb605e3039a2b--