Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130468 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 479C81A00BC for ; Fri, 27 Mar 2026 15:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774624772; bh=osz56p6dAsBl5lrBxZfSv/QpLEchmfasKvR2oWCSlYQ=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Uf/nICSeyk/e+kHxSpJ6Oinq5KvBuXSwNHVYlPR93GUeRhJ9gUJkfvTzo/qbwk89b y2LL+ZH11XC+5iFXOGCgVIp/unKIipJ432pJlnxcLuDpfmS4SLIFB8cO2rSxrKXdjp v5MeB9E9jfLvA+74mkJcA7qf9aaxp/HtcYP5DrqRF4DRNItlSgQoJUEURxSvG4Xj5q ZpStbsuClwD08KgU344SyF5ZArfsgk/lhGtkO+MnuIDFU3nd9oVvczTwszRaATKW+u 6igLm78qQqc4CfWbNRAcmhjXCsofV4NgPKsBUJaJSRbE4GMG9g/bl0J3phh6/f4CvI 1rc10vlXcKW/w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E43EC180062 for ; Fri, 27 Mar 2026 15:19:31 +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, 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-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 ; Fri, 27 Mar 2026 15:19:31 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-486ff201041so20680455e9.1 for ; Fri, 27 Mar 2026 08:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774624765; x=1775229565; darn=lists.php.net; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=HKBrT9HwyUEMxaiQ/6aKnj+KPUkEt4nRWiy4VkDkExc=; b=UbMKlqNFdgk+czJtQLvy7TFqhOr17sBp+nSOOkPHjvKAW6Dhp2Ez/6CJaAwb1shgy3 lPMS05LTMXfhyBtU3HyTc8J1hPEpl0zE/2QXhmY2P7Z6ucOnBlP8At23ppvs0ubzlz7k QIyRgxmqPE/idIqaWMQbCsUk/92xND16HpTtcokYQk5Sg5Y2voL+RWbDn7z6pcrJfrHM 2qiP3c2jhPhIU3j4DwajrSFt0EhkdigyqcEWBbMAFq4asTq8w3STlYqhfi6atcidJebi 4+g/JHWmzW0A7U7BSXLarU0ww5fMJ8IJPFQ6KZq3/+CSZi+5WaVx+Hg2aeczbVxaK1Gv g8YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774624765; x=1775229565; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HKBrT9HwyUEMxaiQ/6aKnj+KPUkEt4nRWiy4VkDkExc=; b=f5XUyLv52jU1gm2eB5w77LPQ0tHHJzKjLnfp2p9MelLcjKnQEl6787MH6bMJtJJN2G c+W8hHVDPfL0gMsf8Jiy4tCf+0pCP1hWYcapywjHYOYLtp4QR5aT22FYvo8lj7jwC4iz UbuuOBnvxcO37+rglKdlWS6OTl/nT3nDU9+MmHJ0C31ogCLev6onEWN5FZMHkjHTMLYh qg51YKav1cuhi8VmNZWblwzjleZCFTFb9K041WqW+PXwKMJA/yA4SIprpXvhx23wUzfm xjNyff5zd3fGOngBVMSnLTnflOGizAUXTUc00AvHZtOYvBzHCmVGu6ij5dxEOTqlvjQN a8wA== X-Gm-Message-State: AOJu0Yy8nyGtYkw75yYzSITRHszpsqqJcn5OSN1pDaS5XNUiWd+EXvl5 GqZHrS8IhsP7/50U87Y/HBS7xoiNvb5DzMzfNaXZY3XEweoJLkSDCMHQmQb0YQ== X-Gm-Gg: ATEYQzxvhmNdw/wxJ2hTudKzTKVL6EKsJzSEztEU8a+TFp5Ila/+Y9akhIZot3t5QAe 9s5Sy4yPxaGQ0lmfoYd4qiOLeplkdI3tSuTURBEInIh/0U4nhVNNdz9KHxhxGrzTKbbUQt2wwHJ yRpfP6wI713UUORBbuVEEJbdmBln5gtNx+jztF4ajrqL4gjMoecZYBr9CbKvAKbe0QkYKYM3WJh vwnpwZfMCMbUCVJCayZ0gPwr27UHjyzfAcjM9nYbTUiu/SyK1ZBHw2S9vUj1fCHCXsoSrE6gX2k pBd2xVqt7bH+R05qRv/os+z7785nE61/yO0xcygXydpyQKSRoka//bhRBhYSi+VHAQs6FLO3Ehg sb2p/0LqOkHuqrNXuJmP34kctJ+EtrBozBZkmiVoXrbKk5ULlRYsuPraW94QxLZJ2SGWCnJD04h LAxO92UrZY3XyIcSN2gBBN+lAkOO7dfXkRQcFt8jjqIiFzyT2V0lsSB0FDpLy0Ss45+PNINi9Hy Cv4Wjx/RBngwR4c X-Received: by 2002:a05:600c:3b95:b0:486:fa35:aef2 with SMTP id 5b1f17b1804b1-48727d59448mr43931775e9.4.1774624765401; Fri, 27 Mar 2026 08:19:25 -0700 (PDT) Received: from [192.168.132.32] (laubervilliers-656-1-64-146.w82-127.abo.wanadoo.fr. [82.127.89.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b919cefd7sm15915215f8f.17.2026.03.27.08.19.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Mar 2026 08:19:24 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------kdfLqcQmq5dina1h2xyw306a" Message-ID: <06a4003b-b74f-4fba-8f96-75fa395ff798@gmail.com> Date: Fri, 27 Mar 2026 16:19:23 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Four Pragmatic Directions for PHP: Simplicity, Arrays, Performance, Concurrency Content-Language: fr To: internals@lists.php.net References: <5c6d66c4-4c17-444e-bb0a-2b8c4759d2db@app.fastmail.com> <48BA5AE0-FADB-4675-B2FC-D56AB7A793CA@rwec.co.uk> In-Reply-To: From: pierstoval@gmail.com (Alex Rock) This is a multi-part message in MIME format. --------------kdfLqcQmq5dina1h2xyw306a Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit In that case, maybe reuse something similar to the null-safe operator ? Something like `$foo['bar']?` With the ability to have some freedom in placing the `?` character. This way, you have both syntactic sugar:     return $foo['one']?;     // is roughly equivalent to:     return $foo['one'] ?? null;     return $foo['one']?['two'];     // is roughly equivalent to:     return $foo['one']['two'] ?? null; And here it gets interesting:     return $foo['one']['two']?['three'];     // is roughly equivalent to:     if (!isset($foo['bar']) {     trigger_error('Undefined key "one" in ...', ...);     }     return $foo['one']['two']['three'] ?? null; This brings a "new" way to deal with nested array keys (like explained in the first code samples). I don't know about the parser yet, but technically, in language semantics, it is a unary-right, contrary to the "?" operator which is binary left&right and must be used alongside the ":" operator. Would need an implementation and some tests to ensure the reliability. Le 27/03/2026 à 06:26, Dan Liebner a écrit : > > On 2026-03-27 03:58, Rowan Tommins [IMSoP] wrote: > > On 26 March 2026 07:51:31 GMT, Rob Landers > wrote: > > > > - an "optional key access" operator like $foo[?'bar'] that makes > the intent explicit but concise > > So, syntactic sugar for "($foo['bar'] ?? null)". > > > That, to me, would be a massive improvement in terms of code readability. > > On Thu, Mar 26, 2026 at 11:40 PM Morgan wrote: > > On 2026-03-27 03:58, Rowan Tommins [IMSoP] wrote: > > On 26 March 2026 07:51:31 GMT, Rob Landers > wrote: > > > > - an "optional key access" operator like $foo[?'bar'] that makes > the intent explicit but concise > > So, syntactic sugar for "($foo['bar'] ?? null)". > --------------kdfLqcQmq5dina1h2xyw306a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

In that case, maybe reuse something similar to the null-safe operator ?

Something like `$foo['bar']?`

With the ability to have some freedom in placing the `?` character.

This way, you have both syntactic sugar:

    return $foo['one']?;
    // is roughly equivalent to:
    return $foo['one'] ?? null;


    return $foo['one']?['two'];
    // is roughly equivalent to:
    return $foo['one']['two'] ?? null;



And here it gets interesting:

    return $foo['one']['two']?['three'];
    // is roughly equivalent to:
    if (!isset($foo['bar']) {
    trigger_error('Undefined key "one" in ...', ...);
    }
    return $foo['one']['two']['three'] ?? null;



This brings a "new" way to deal with nested array keys (like explained in the first code samples).

I don't know about the parser yet, but technically, in language semantics, it is a unary-right, contrary to the "?" operator which is binary left&right and must be used alongside the ":" operator.

Would need an implementation and some tests to ensure the reliability.



Le 27/03/2026 à 06:26, Dan Liebner a écrit :
On 2026-03-27 03:58, Rowan Tommins [IMSoP] wrote:
> On 26 March 2026 07:51:31 GMT, Rob Landers <rob@bottled.codes> wrote:
>
> - an "optional key access" operator like $foo[?'bar'] that makes the intent explicit but concise

So, syntactic sugar for "($foo['bar'] ?? null)".

That, to me, would be a massive improvement in terms of code readability.

On Thu, Mar 26, 2026 at 11:40 PM Morgan <Weedpacket@varteg.nz> wrote:
On 2026-03-27 03:58, Rowan Tommins [IMSoP] wrote:
> On 26 March 2026 07:51:31 GMT, Rob Landers <rob@bottled.codes> wrote:
>
> - an "optional key access" operator like $foo[?'bar'] that makes the intent explicit but concise

So, syntactic sugar for "($foo['bar'] ?? null)".
--------------kdfLqcQmq5dina1h2xyw306a--