Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130578 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 457691A00BC for ; Sun, 5 Apr 2026 14:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775398301; bh=BUf6B4ldDNRRVk+6Tpfped4WKQ9XBVSzXTXpZ+wGrhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7OozlkILbhnuYSkegKW9pekJ94zHpPWN6sMY7RzRmTJdtcp7zuo0pVkg+dOe2uOB LNNk7l/gcEH3H4HhRdPowGukOWTud7WhqifSiBC7EFJBXIiOqJpdyTRvR8fOqkAZg6 sYI2pr0O1iFwjsH0Idn10OrENRMsflKe5r63KSytLrFD0SfgoM2BqNm7kpN8RJOn5b bWwfSrER0Lx/JOwX+yIPYYu7sr7VH/uT0tUvTSoFwJNl53Ma8t7vbPhT0JtfIO0NhT o55dwUq5zxnoR40PEs3SlW3eIf3Yw//c+jf+JW6MofwJL4UheCq927fa0g+rz8ulJb aZspa3MBXs4Uw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 41DFA180057 for ; Sun, 5 Apr 2026 14:11:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic.asd.mail.yahoo.com (sonic-euwe4-0022.asd.mail.yahoo.com [34.2.86.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 5 Apr 2026 14:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1775398293; bh=C3LWk7SWdaGDzAXSrWmvzbMLLxcODQBzv6BLDAMenQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=aDxLCdZHkXhq6UYXhULwubt8J8WAKPotuliL2ZzHZOA64IoHgnFETke4Kmnks/47v6zCWfsVgpWKstPOed7BVPkQ4tTDu3T23XB9PWeUQoQctJdqqjSS4Ur06+JNQZ/j3d0lt2oLWK8WoLdw7oMP8t9gKmMLsTr6r2Yh9efvRZKi8VMIL/fla07//rUZT+0VzRN2rUlouTMNL0JXTwfnq3w1Qad0jhnS3pUWqi/y2fiGl1B8FEESxdbgNNUxX0Fqfm+xKXLGSOrnqiI8YfF2RzNV7qG070gfTsKFrdGpR0SQe7aCmF+TIFTf83flsIUy5Pamh/CPjd4MmuTJ5BaTRg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1775398293; bh=aOhBzQH+WHkl5DCWZcmT6xDb/uVm5nH1nadpbEEyFFs=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=FLZgLONq6075vgqDVx+iqLKTBlPYvufKk9t4o1njE8ggNKAQGI2tfSP+Fo0DqdppIPojylKYs32kIosJ3y4R1U1Skx0I9M4mIMw6lYR4fURi9RL41UkIyQb1YGLkmYr7/MPgpKiNRv5cepB0HT0m1vrrapm+9vvkX2x/T/kEmRBOh2D1RXkr1PC07VuEovXIq19g9dzsf+Gix0pP9AYYBakzoc3Qkdj6Zv8ih8berNkctx8/PKKahsEsOoTl6MDVe4bJa8ZSWCVKXlhtO2eBehFcdIr+n3j1PwPgzgSlvtiY9oXZqXZVajqXMzEt2V22ty0qDbz1fUZo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DVTaBv4gyvJITj5KXczEtpD9YnylF7DZeKXkV2sLRLiwlfDpY9ewR8C_lq412nnjzNeNvGOJXQI9 2wLu80JHGBI6IiOTbpezG_xPu3FaUjFFjqEfl5iprPbKhG77mTL5WgP9NX7nLk8gO3sGUSibiOBb kAT1ihHYHGLcMszf9aFm.j55avqG_0.ABL6L1s5N5urvT9FRlqRpz5IumoufFpqNzNchhHHnWwmq hQDkCpK_u6oweBpz1EBXgV.JsaWmVaZ6FTvwU4SL9sFLOkOpa9Lhl4oEYp66cYYUL60NabndAZ2t H_EcrNcVvj4KrsYw5O8jA1mgrjbyXZBIUWQXtuL8LbqW8OfuJ2f0AvQDsyWI7VZqj6OEC2OcHxfN 41jnGOSDgD7zdhpCi6YIhnD2_jlsJJotIXHex65J6.CgAesaOSYjzGAY7ikBx_HRAZxyC4cy5BtG .eDeUArkXbC6I8Jmx2xRsiwsT6hSD8BcKyoxtNljCBQtp3q16lY8EIMaNJZNIDwKpgxecTnHxib. oyQia4Z4g9HAj7S6d7Jk2uo4lGnqnQicELjGVgKoJV99gctVmKgnwTzBYHbk.Wqa_VOs2Uha1ebA jaIpmIQjI8Y3z_bx8_asfH8HAHNRiicId6C6IApaC4FueYDSt7QBd_fBeBkC2HLh8cg3zHNfNOxj VRy458VecSPvoq1a_UL7fXfIhx3lThUKvC8guzvqAXo4tLxv6mJ2RRApIA5Pb1fSDrRsaBCZvuQP V9MTyaGpeiFRh_gDx5XIzq99liBT75lo1X8WrwaCuT0plGRwPtD6CEiNnwPyB46ayWaiZmvFwvrk QDhsygvyT0UNDRZwN7t03D2wjyi3z3QSxkTAN6LosL2eVcDo4.lW6eKoQBSuay_07TbB2vJYRXon yoUleAJ4c74T5scgbbA-- X-Sonic-MF: X-Sonic-ID: c2a7bcdc-7ec2-4d8d-ab9e-27c25d0add69 Received: from sonic.gate.mail.ne1.yahoo.com by mail-asdoutdeli-p-cin-euwe4-prod-sonicconsumer-svc-102 with HTTP; Sun, 5 Apr 2026 14:11:33 +0000 Received: from dip59.lsn.ir2.yahoo.com ([87.248.99.68]) by hello (SMTP) with SMTP ID 71f3178f636d77c4815364b169e4c8f3; Sun, 05 Apr 2026 14:11:28 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Message-ID: <1775388386735.2733149565.1017617879@yahoo.de> To: barel.barelon@gmail.com Cc: internals@lists.php.net, Aleksander Machniak Subject: Re: [PHP-DEV] [RFC] [Discussion] array_get and array_has functions Date: Sun, 05 Apr 2026 14:11:27 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.9.3970.47 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 From: hanskrentel@yahoo.de (Hans Krentel) On Sunday 05 April 2026 11:31:11 (+02:00), Barel wrote: > On Sun, 5 Apr 2026 at 08:17, Aleksander Machniak wrote: >=20 > > On 4.04.2026 16:06, Barel wrote: > > > This is the link to the RFC: https://wiki.php.net/rfc/ > > > array_get_and_array_has < > > https://wiki.php.net/rfc/array_get_and_array_has> > > I'd prefer $key=3Dnull case removed. It's not that useful, not on pair > > with array_has(), and one would debate what to do with the $default in > > this case. > > > > I'm not sure this needs to be stated in the RFC, but I hope they do = not > > throw a warning when the key does not exist, on any level. > > >=20 > Thanks for your comments. I would like to hear what other people think > about the `null` case. I find it useful but if other people think it is > unnecessary, it can be easily removed. In any case, the $default would = not > be used in this case Technically speaking, this scenario does exist; the problem here, if = I=E2=80=99m not mistaken, is how to represent or handle it. You originally = suggested using the null value for this, which, to my knowledge, is one = approach. However, this dilutes the parameter=E2=80=99s meaning, much like = it does with =E2=80=9Cint.=E2=80=9D A common and long-established approach = is to use only strings for the reference tokens (=E2=80=9Ckeys=E2=80=9D). Since =E2=80=9Cnull=E2=80=9D is then the empty string (z-string, empty = string, null string), the dot notation in your path can still express = this=E2=80=94it would contain neither a dot nor any character=E2=80=94but = it would be ambiguous, as it could also mean an empty key for access or = just be string zero, just the default string value, e.g. never a name or = reference. JSON Pointer resolves this by prefixing each =E2=80=9Ckey=E2=80=9D with the= separator; accessing the empty key is then =E2=80=9C//=E2=80=9D (or = =E2=80=9C..=E2=80=9D in dot-prefix notation for illustration) and accessing= the container itself is =E2=80=9C/=E2=80=9D (or =E2=80=9C.=E2=80=9D in = dot-prefix notation)=E2=80=94the null case discussed here. For the iterable access discussed (an iterable of reference tokens instead = of a string with the dot path), this is then no longer ambiguous, since = null, as originally proposed, becomes the empty array and not an array = containing the empty string=E2=80=94problem solved. So, if one considers = allowing iterables, it becomes possible to avoid the null case and use an = empty iterable instead. In this context, the notation [] is probably even = more meaningful than null. I hope these thoughts help you think through the whole thing a bit more = carefully. Technically speaking, after removing `null`, there can only be = one other `null` case: the empty string. Switching from postfix to prefix = notation can help with this and also prevents empty strings entirely; and = regardless of the discussion about iterables, removing = =E2=80=9Cnull=E2=80=9D boils down to the fact that if you want to support = both cases: access to the holder=E2=80=99s value and access to the = holder=E2=80=99s empty key must be resolved into a single case, and you = must specify which case that is, since you cannot express two values for a = single value, and keys or any other type of reference must be unique, = otherwise they will obviously become unusable too quickly. In my opinion, = it makes the most sense to resolve the null case first, since all other = specification errors related to ambiguity only arise later (e.g., = insufficient escaping rules, conditional access to the existence of a key = based on fuzzy logic, etc.) and this provides the precision needed for the = cases you want to support, whether it=E2=80=99s postfix or prefix notation = or whatever. In practice, it doesn=E2=80=99t take much effort to pass the array via a = placeholder when calling the function: $value =3D array_get_dot([=E2=80=98=E2=80=99 =3D> $array], =E2=80=98.= =E2=80=99); This serves as an example of the null/placeholder/null key scenario in this= context and highlights where there might still be some ambiguity with = postfix notation. A third function that lists all dot paths in an array could be helpful for = discussing and testing the RFC: // The function array_get_dots() returns the array of all dot paths of = the array in breadth-first order. function array_get_dots(array $array): array { ... } $dots =3D array_get_dots($array); With a small test data set, simple property tests could be performed, which= could then be used as examples in the RFC to formulate the expectations. The function names in the two listings are for illustrative purposes only. And yes, in my view, it makes sense to remove =E2=80=9Cnull=E2=80=9D and, = furthermore, =E2=80=9Cint=E2=80=9D from the first parameter. Because of the dot notation as shown, the empty string as a value for the = dot path should trigger a value error due to an empty dot path, as removing= =E2=80=9Cnull=E2=80=9D alone does not fully resolve the ambiguity issue = for the null string value. >=20 > And, no, no warning will be thrown if any part of the path does not exist= , > being able to easily support not existing paths is one of the main = reasons > for this RFC Thank you for the clarification! This is in my opinion good to clarify in the RFC as well, as it is commonly= known as error handling, which includes writing what an error is and what = is not an error and which diagnostics are guaranteed by the implementation = (for example, no warnings/notices.) --hakre