Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130476 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 41C8E1A00BC for ; Sat, 28 Mar 2026 18:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774722673; bh=MtbGrB9MEBW9k7AVpImheN7ZuIE47IFsslvO4SYC+jM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=iB1pBSavoZl7CVVibct29esTN9RJOiEoaKwtitDDVjf0VhrNxxfRI9DGkwvvm7p1s vbCjfahiEyLZPGbjFW1t8+MMU2Z3VT/+FWyooDGi7PxVBZraVuHhZ2pRVMc3AFw/hG L+6f2uT3Z1uYtf2ksFMcUm4jkninJ6cjVp23V1z/RFRCOGW4LF7eOurWdGPB3ynx3e mSpafoqfgGr7i88lDiCCuq9DQUP5KgeonN4ItHi2Gu7GBvYfysAyhL+bSTitL+eDRV xjrbrKMuwXMRj7m4c+NJ54gzJZpoKLOyvDPFSVHwuq2h/Un7p/u5wSSoTqxPwoK0Ib gSwCWz/GtlfhQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F1E82180083 for ; Sat, 28 Mar 2026 18:31:12 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (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 ; Sat, 28 Mar 2026 18:31:12 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id AC1C814001B4 for ; Sat, 28 Mar 2026 14:31:06 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Sat, 28 Mar 2026 14:31:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1774722666; x=1774809066; bh=QcEzDddzcTeOv9kHUIH/U7ymH1ZaD8rYOCbOzuujCOI=; b= OvOSzIDX7PBuO8luoY1YTXr//TFYa1A2MUdU0zChApN5iST8OqVe+laznxiGn6NG i+9ZrXfmIzgLPYAbnBXszOMApi98S8PvHQ7/EMgINmeEhho1lFcWJd/6hn+Mgfbv vKHH0xs6IXTmUY8NdnTCt6HRzO8OqjhAxpPA/5goL3GRP7dtyEqj+0oyZBlEE5P4 ZewMvpLUVA2Xo6euaU6U6Majq65/Vr+BSnSWx6mtQmOETM6FJE3PiVZpXrg6NyID 9BlDHv7AaYLaE9op8l4LhRbSbTOL75QMZu2GbQp0SIvTM1Xot+d+wZWhkwpF9PVI v5+DTFa10H+eHwMkWJH+mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1774722666; x=1774809066; bh=Q cEzDddzcTeOv9kHUIH/U7ymH1ZaD8rYOCbOzuujCOI=; b=NnenQaBM/dtOknV6h MhdLawStrvBdAhLxEDlyfIjviyj4OGCWNcRTNen1KTmzaSO5MjbieXof5hY1tP7s jurGunEGD0F8OgKumuh4ebXRY8ijUDNFwJDF2n7Lti+I59fdsSIxR6FYskrBk+1f QIHLsOnljEvMSw+6FOlfop4YapGh3iVVwjh/KXA7bzGWb/PMRkACtkDACQYcOWct qBxyWwt2IGh93dtNLpNlowcKTL32pw90GLktPFqpz6humPSI8Zr55d6ugNLgw15L e7zU84WMPX9UOjQcu17tcVeGyjPiZg+qhhrA1AkOIy+kE1vJsACCn3+OthLIvTyP y/rSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeffeefkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeffke evudffuddvheejvdefkeelfedtudegfeehjeduheegieduffeggeegveefheenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphh hpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 28 Mar 2026 14:31:05 -0400 (EDT) Message-ID: <759fb4e0-4c89-4065-b6dd-abbf297213ac@rwec.co.uk> Date: Sat, 28 Mar 2026 18:31:06 +0000 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 To: internals@lists.php.net References: <5c6d66c4-4c17-444e-bb0a-2b8c4759d2db@app.fastmail.com> <48BA5AE0-FADB-4675-B2FC-D56AB7A793CA@rwec.co.uk> <06a4003b-b74f-4fba-8f96-75fa395ff798@gmail.com> Content-Language: en-GB In-Reply-To: <06a4003b-b74f-4fba-8f96-75fa395ff798@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 27/03/2026 15:19, Alex Rock wrote: > > In that case, maybe reuse something similar to the null-safe operator ? > > Something like `$foo['bar']?` > I think even if you could make it work in the parser, it would be hard to make that read well with the ternary operator: $foo['a'] ? ['b'] ? ['c'] : ['d']; >     return $foo['one']?['two']; Looking at that, it's not obvious to me whether it's 'one' or 'two' which is optional. return $foo['one']  ?['two']; return $foo['one']?  ['two']; > And here it gets interesting: > >     return $foo['one']['two']?['three']; >     // is roughly equivalent to: >     if (!isset($foo['one']) { >     trigger_error('Undefined key "one" in ...', ...); >     } >     return $foo['one']['two']['three'] ?? null; > You can have the same ability with a ? inside the brackets, and without the ambiguity: // all three keys required to exist (as of PHP 9): return $foo['one']['two']['three']; // 'one' and 'two' required, 'three' optional: return $foo['one']['two'][?'three']; // both 'two' and 'three' optional: return $foo['one'][?'two'][?'three']; // optional all the way: return $foo[?'one'][?'two'][?'three']; This would maybe have similar short-cut semantics to ?-> $foo = []; return $foo[?'one']['two']; // OK: the ? neutralises access to the missing section of the array, short-cutting to NULL // Similar to $foo?->bar->baz when $foo is NULL $foo = ['one' => []]; return $foo[?'one']['two']; // Error: the ? had no effect, so we're trying to access non-existent key 'two' in the empty array $foo['one'] // Similar to $foo?->bar->baz when $foo->bar exists But an RFC could pin down those details. -- Rowan Tommins [IMSoP]