Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130580 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 429B01A00BC for ; Mon, 6 Apr 2026 16:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775491537; bh=qnwV/YaCkIDmVbgl0WpHAZ864x7IMjir3dgDtS4QTI4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Didzz2JYFDpRk+8O/43x6f9sWrGdxIQjLGHggbXJMAV/iiOxzoabwzUii1oZ9zioj 3aXeOWGvzo9C2rQ42Xe1ZfCH3o7NhgFRMxu1iuMpEbU1O1Cwo6hXJzsqap2Abcwra4 Mm7R21q2q2j5LdW913eBgrElQO0ZpdbEsy4zGNwqT602TLp9WqGuad/QkXBSZLQqh2 WiRsUzSgOYYezjiUiQX9VN5U885MaEUuSbVoxmGN7YgcHoPkZkyHZ5HwcsDG/9y/KH tg9b6OI7saYDxM1WVCB6Npp8vuXJE/sDC5K9bDt1sZE5u2txXhrKF2uqYyglSwK6Mv Wp9nNoP0WpZ3Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DBC1C180078 for ; Mon, 6 Apr 2026 16:05:36 +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=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f181.google.com (mail-vk1-f181.google.com [209.85.221.181]) (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 ; Mon, 6 Apr 2026 16:05:36 +0000 (UTC) Received: by mail-vk1-f181.google.com with SMTP id 71dfb90a1353d-5675d609621so3371325e0c.2 for ; Mon, 06 Apr 2026 09:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775491531; cv=none; d=google.com; s=arc-20240605; b=RJes3qy5OO7f/UQ90rMt2dixaO6BMXiusv0OS/kRpG2pZ0EO9R+92dvU4RdIOsiQ0Q VAnba93KxsJAZfgzMKPD6kvI0btmWxS2t0cE5sKK27KG7ZlypFW5BZiuqok0KMUZPuJg C/r2Otn5/JTR4sxIUpca1Eou5EZgXNldWn9JcNDu587ZuBOxG/4FBnpNNz+c6+mPpGgt ASTFgWof/CcMO5a6Qx8CeRCoas/oiIIyBguhUh8/pPKYNS/FEIvRq5zcXE7ib5S5wxPM lQKzC0b90QawRwHaTakL7kiTB5L9Pljka586xA3pUnJw+SG6+97w86vCgBEmGXy8lMOa p/yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=qnwV/YaCkIDmVbgl0WpHAZ864x7IMjir3dgDtS4QTI4=; fh=H+xpp58yGTMflPDUjzzUel7JOjczCf84ecYRcBizoTc=; b=RSS4jBdX1VJB+0eTHW0+qkAz5W7ayEVdU3efQS1mHo0oNKNKLayC8jUmFUrbW7418D D+j56rmCZXjbK7Kpv7m5AEsG/YH5CnW5W1xgSmOUItQ9msNYLiQrnyvQxqabhUx7hr/p QNmkKVvdePrTfSjffB+kwE8Yo5s/8+zLGRKT0UBDONZWEbY74oOzM8e09naiypkb4jPc QMTR760wjC4c6wK4QfTsvsAY3S+61pLrTDQLlJpuOh3MEeii90UPb7HxyTVKwGkZ4LFk j36KtkgUuhGPallqWWOwJNVEQb0iglHDKnwjIA34esMoxUkLG3tOgc4YHoOD/q9KCZTb muxw==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775491531; x=1776096331; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qnwV/YaCkIDmVbgl0WpHAZ864x7IMjir3dgDtS4QTI4=; b=fTjGYsHbDg/fycYLwI5qDuTLC3hENWz7SWOG3gBHujgyNNST8f6CB6lpn1WeJHffkt 6vK9kGpTggmMWVpqa75DDcLh6qFPhwBDkKQanlXGcU9nqs+z+rO0xlZx427Is/guJczk tI8K5uWK+9mpirl9Kmi5gJZSwBfU7mL05iEnpOXKKN2PEQqDlP3u8NiduOcMIIj1W6qP s+8tDkzgqAljkSNhcEh2NcYFoQ6MlnlOKm15qoJ3lvewT3SV/pIXGIw41Uvgrs5CJPUU jaygWFFefWoUmlFeSWyPCY0YKlZdQwfL1ouGmPbr+nAAqN4r+KIkIpZ+uVwNZr6491yW C+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775491531; x=1776096331; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qnwV/YaCkIDmVbgl0WpHAZ864x7IMjir3dgDtS4QTI4=; b=Q0MN3euUCmusxbxFfprTlk2l4lIXcMcX9IIbS/9Gb04rfnHBIt0atMgI2Hs5KFphe+ fOIEotPURKFF667VkVVaCToMtvKpEaLV8+zAzBplP18ep3zDpP7CIpZdVhTIzpREVUu/ cwnZryKKGwaOfVFrcw94r0Yt3OWp0bdgg+wS1x8I6ORjifcos1oo9aKHDczPSdRm+L7Y HJiZnq/mNDnkcY9kDjs3RtNOTCaUc180R8qmjw2M4AhqYSiqD/YVu7One1DsODS10KTd SdETpo1m7uewDiNUXiVPWBAJ6uyRtmUnlPfbvUTc5jVwPUd5TsQGu1SX1KZl9EnKunq2 L0Bg== X-Gm-Message-State: AOJu0Yxw68sLgLViQdHDfD2ZjIuKRRonfyuPMLtAnzwlLmRtdsCnqL23 aDKaDvnge69MoHe4/tGR9nsQ8oCLnf0nKch63sfPQU7gHU8n6+POc2YKiGI80meu/h12Ojn4m6Y 5g6BWPwPfwXe7wIcCqWYRdWrYS6jgxHs= X-Gm-Gg: AeBDieuzlGwXFRDrqA3w6T+gf13kC7fSyGJ3E0HHV+XmCql1eRuo62gQtJf1u2UPA9Q ehh+xiEKY6eeM69TWIAYB8grbbv0XYjUcu3kqvmezuY/fRxRc0pQqHBiLj2aoJKofRi/BRuzXZS 2Hbisxjq0fstS52uEp41PU6dafuS+7ZJSDUajySUh2XNN5Wcy0Mr73SZ8F1BJ2k5OPkPdHbxfgR ln7JP+KrUKSs8hUtf56rnTmcHhE7Awk/dfFxh3nHDoULzWeHGmY2xsNsX+HJVjgvD4VI9HqK1aY G1wGQLSpmbPSOyfgzA== X-Received: by 2002:a05:6122:4b8a:b0:56d:8ded:796c with SMTP id 71dfb90a1353d-56dab86c21emr5084083e0c.4.1775491530893; Mon, 06 Apr 2026 09:05:30 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 6 Apr 2026 18:05:20 +0200 X-Gm-Features: AQROBzDtXWLU3wDNNvgNWN_a41VRxRfTXNkU2CjhVIKVTyRCl3G6L82kg3FoDfk Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] array_get and array_has functions To: Barel Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000002e0e064eccd6ff" From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --000000000000002e0e064eccd6ff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Carlos, The proposal looks simple on the surface, but it implicitly introduces a non-trivial policy for interpreting array keys, which is problematic at the language level. In PHP, array keys are intentionally loose =E2=80=94 any string is a valid = key, including ones containing dots or other separators. Introducing "array_get()" / "array_has()" with dot-notation means that a plain string key like "'user.name'" is no longer unambiguously a key; it may be interpreted as a path. That creates a semantic conflict with existing, perfectly valid data structures. This is not just a syntactic concern =E2=80=94 it=E2=80=99s a shift in the = data model. The function starts encoding assumptions about how keys should be interpreted, rather than operating on arrays as they are defined by the language. We can already see that this space is not universally agreed upon: - Laravel and Symfony both provide similar helpers, but they use different path semantics. - Questions like escaping, null handling, distinguishing =E2=80=9Cmissing k= ey=E2=80=9D vs =E2=80=9Cnull value=E2=80=9D, or supporting ArrayAccess / objects are all p= olicy decisions, not language primitives. Because of that, these helpers are inherently convention-driven, not semantically neutral. Different ecosystems solve them differently, which is a strong signal that this abstraction belongs in userland, where such conventions can be chosen explicitly and consistently. Putting this into core would effectively standardize one arbitrary interpretation of array paths, while PHP arrays themselves do not have such a concept. Additionally, allowing "$key" to accept an "array" further weakens the conceptual model. A variable named "$key" strongly implies a single scalar identifier, while an array represents a sequence of path segments =E2=80=94 effectively a different abstraction ("path", "segments", etc.). Mixing these under a single parameter name blurs the intent and makes the API harder to reason about. In short: "array_get()" with path notation does not operate on PHP arrays as defined =E2=80=94 it operates on a particular convention for interpreting keys. Tha= t makes it better suited for userland libraries than for the core language. Kind regards, -- Micha=C5=82 Marcin Brzuchalski sob., 4 kwi 2026, 16:07 u=C5=BCytkownik Barel nap= isa=C5=82: > Hi, > > I would like to open the discussion on my proposal to add two small, > focused array functions for retrieving and checking nested array elements > using dot notation. > > This is the link to the RFC: > https://wiki.php.net/rfc/array_get_and_array_has > > This is the link to the proposed implementation: > https://github.com/php/php-src/pull/21637 > > Thanks!! > > Carlos > --000000000000002e0e064eccd6ff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Carlos,

T= he proposal looks simple on the surface, but it implicitly introduces a non= -trivial policy for interpreting array keys, which is problematic at the la= nguage level.

In PHP, ar= ray keys are intentionally loose =E2=80=94 any string is a valid key, inclu= ding ones containing dots or other separators. Introducing "array_get(= )" / "array_has()" with dot-notation means that a plain stri= ng key like "'user.name'"= ; is no longer unambiguously a key; it may be interpreted as a path. That c= reates a semantic conflict with existing, perfectly valid data structures.<= /div>

This is not just a synta= ctic concern =E2=80=94 it=E2=80=99s a shift in the data model. The function= starts encoding assumptions about how keys should be interpreted, rather t= han operating on arrays as they are defined by the language.

We can already see that this space is= not universally agreed upon:

- Laravel and Symfony both provide similar helpers, but they use diff= erent path semantics.
- Questions like escaping, nul= l handling, distinguishing =E2=80=9Cmissing key=E2=80=9D vs =E2=80=9Cnull v= alue=E2=80=9D, or supporting ArrayAccess / objects are all policy decisions= , not language primitives.

Because of that, these helpers are inherently convention-driven, not sem= antically neutral. Different ecosystems solve them differently, which is a = strong signal that this abstraction belongs in userland, where such convent= ions can be chosen explicitly and consistently.

=
Putting this into core would effectively standardiz= e one arbitrary interpretation of array paths, while PHP arrays themselves = do not have such a concept.

Additionally, allowing "$key" to accept an "array" = further weakens the conceptual model. A variable named "$key" str= ongly implies a single scalar identifier, while an array represents a seque= nce of path segments =E2=80=94 effectively a different abstraction ("p= ath", "segments", etc.). Mixing these under a single paramet= er name blurs the intent and makes the API harder to reason about.

In short:
"array_get()" with path notation does not operate on PHP arrays = as defined =E2=80=94 it operates on a particular convention for interpretin= g keys. That makes it better suited for userland libraries than for the cor= e language.


Kind regards,
--
Micha=C5=82 Marcin Brzuchalski

sob., 4 kwi 2= 026, 16:07 u=C5=BCytkownik Barel <barel.barelon@gmail.com> napisa=C5=82:
Hi,

I would like to ope= n the discussion on my proposal to add two small, focused array functions f= or retrieving and checking nested array elements using dot notation.
This is the link to the RFC:=C2=A0https://wiki.php.= net/rfc/array_get_and_array_has

This is the link to the proposed= implementation:=C2=A0https://github.com/php/php-src/pull/2= 1637

Thanks!!

Carlos<= /div>
--000000000000002e0e064eccd6ff--