Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126312 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 qa.php.net (Postfix) with ESMTPS id 3B2961A00BC for ; Thu, 6 Feb 2025 19:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738869263; bh=dyKrVNMdjT6b6zt4o+zvqDQZICh+iqQle+h8lqrVYoQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=VJrsSd6X7uxzNvUYoz988OTA/zpfJDxEkAkeT0P22xv3cIBegzlMH+VwlcTARTRgz 9LSB0jJN2rKtBmdk/o0lfUeV4RfvZlEmWGnYtQi3OJWIYc2bIW3s/ehSfsU1hBKr0t ulWUcAwdVb6tq6IRmNHNx42HlJywglk2GJ7GhJMTEWZYZB8+jItxHwdB66qNSxolIt KAI4KtUPH5nghX1ac3l29Khs+YmJ2nhlFQbC0oB+adF9wbRPAIFLbPCfpi6AGgJ3vI 2qdIDtc7ReKrDkFljly0TARShvLKIG25Iz4INUyG8YAcewy5KqqGB0UdcSQ8J1oOq6 mPNR9K94ICaqQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EBECA1801D5 for ; Thu, 6 Feb 2025 19:14:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 ; Thu, 6 Feb 2025 19:14:22 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4F3CB25400E0 for ; Thu, 6 Feb 2025 14:17:07 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Thu, 06 Feb 2025 14:17:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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=fm3; t=1738869427; x=1738955827; bh=c6uJ8w8H9pxZMwMOkJAM0 wG2NHQTLIPbMlMVcw2Vphs=; b=Jq2VGbZr3RmC1oYWABTvL50BE4jwEoNAlS0IK JanWc1UbIlV/nS+MvCdowQxG9le+JnhT+gcP3rFuxKaUGbTIrhET/pU5cjjheDbW 9jWttME2FDC2koCUKJxuZ7VWJnTK2fSeJpI5NoMbwjh9S175W4H/V97EXoHF2MMa GstkLrtUSkaPSfuY/3kz1BPzbfnfLLUkIfEll6X+BuIpOINBglx9CZKfdW0DbJnX 2x/716l5LaRtEajTjW+DhVWc9ursrnZDvtUscEfcnpFM9p7H9Yr1HkfESvSFgmUv uWv1Fu3sz4Nfx5wg0snIDm+2U+27OGQzuwbmdU/FSGF3t0Kzg== 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=fm3; t=1738869427; x=1738955827; bh=c 6uJ8w8H9pxZMwMOkJAM0wG2NHQTLIPbMlMVcw2Vphs=; b=LPfv6JjqxtvV+pp09 fMxogxDjW9iG16iA7w7mmidZQdAXZ9rEWNWyXuHW3nRMG884v3amIGa6TTerMx7N u1GnB+QwMF2AOIdELWYATdzy3h/Deubhm5UVAqoqvW1HAksRGPP/PiTfH+7HXlkt VFLCUnB+XP1PjLEg+N9jfiecXaZnCBHhtxO1FePeIj8Gz4AJJK305xJM05kGj9mQ PX8dmETzx/ryEN5QUVd2UPVJQGx7gKdly6jhEmK0oQZ/l6vGNEBfAbSOSIJVu96q 5NyNn1ZxAveQbnYu3mMXMLbnK6HOLg7AaOvNrnurIzrNmcd0oOKAk6MRHP796iCc 3wYzg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvjedvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepudegvdelgfeugeehfeej teffudevleethfefgeejffffleegtddtveekgeekudfgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgv tghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtph htthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5797329C006F; Thu, 6 Feb 2025 14:17:06 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 06 Feb 2025 13:16:46 -0600 To: "php internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] RFC: Not Null Assertion Operator Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Thu, Feb 6, 2025, at 6:50 AM, Mihail Liahimov wrote: > Thank you for your answer. Now I will give examples for better > understanding. > > Simple examples from Typescript: > > let foo = ... > foo!.bar() > foo!.someProperty.baz() > > Examples of potentially using in PHP: > Without this operator we writing this code: > > $foo = ... > > if ($foo === null) { > throw new FooIsNullException(); > } > > $foo->bar. > > With this operator: > > $foo!->bar > $foo!->someProperty->method(); > $foo!->someProperty->anotherProperty!->method(); > > I think the postfix operator would be illogical in PHP because my operator > is similar to the existing nullsafe operator in syntax. And it would be > strange if its syntax were different. > Or we can implement both operator syntaxes: prefix for accessing > properties, and postfix for use with variables, as in your example. I am struggling to see the point of this in PHP. We don't have a compile-time check for that kind of null the way Kotlin or TypeScript do. At runtime, it would already throw a value I cannot control. With this... it would throw a value I cannot control. How is this a win? --Larry Garfield