Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129029 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 1A4A31A00BC for ; Fri, 31 Oct 2025 13:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761917994; bh=BsbongHh32TYhNxlTMcSAVH5qKa1WB1HJxUGhAMOmKU=; h=Date:From:To:Subject:In-Reply-To:References:From; b=epye9q6UdcOygffApbg9FB63YLvhS+Q+ksqBVyswF7jlIomSCcIwHVKJAMvC6oKE9 7ZP2TNBOYw4sKP5rYyI28rTYwUEOrjRxCcmFvytuxAJAvo2oIFVMn/6Czf0FV5K2IX PjMaEUVBFTPlMG4MmkoiznXfV9zpMY+hLduY+C1Wt+rS0+YXs4bR1YDcZiUvJ9SjIU LI+NUDfIyNA5pgm/6M+OgVEU5PgliLHGhkoyNCIDvrT37xj75cP4XiIoMs1T4xi+nf DIA3pqW4BEiYPf+FO5snwd0iDwOKYI5YgZTW09CSSO95JxB1cRCV7nUHzRHM7JbR08 iA/9ten0OGP5A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B63E018002E for ; Fri, 31 Oct 2025 13:39:53 +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=-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_PASS autolearn=no autolearn_force=no version=4.0.1 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 ; Fri, 31 Oct 2025 13:39:53 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 070BC7A0150 for ; Fri, 31 Oct 2025 09:39:48 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Fri, 31 Oct 2025 09:39:48 -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=fm3; t=1761917987; x=1762004387; bh=BsbongHh32TYhNxlTMcSAVH5qKa1WB1HJxUGhAMOmKU=; b= LzuQZG6rLPdxQL0Qc1I4+pxYCBiW109vwywg9chkcGjPlfguJ+iXvSk/6mrOJx0L XuaQa14bPpusS/rMx4QtnyTdFSB89yenfEQnK8/oGSa3ca5nNdKYRPodaeWjb1wE WDreKh7gwoqIM8v03XfsLutdI9WXbRU9al15ojsD1SxDJQLg2Pri8vtVqqAiZxzJ GXzQlKRZXL+AvN67sAK1UKHfOrZFnUuG4Y+b1cLrReUIaIwsbmCH1KKeI0GRGT5D V+m5+FyaUm63K3INASxNZHYfza4KNyVSzsjx/Ux7sx/gofvtu6v5MbB+7SAJ0Xhr pBuAfa3IhoZqdKFnecTrMQ== 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=1761917987; x=1762004387; bh=B sbongHh32TYhNxlTMcSAVH5qKa1WB1HJxUGhAMOmKU=; b=ZIUh5uvr+SOfZpzf1 9VTYKOovkZzVWb8RzjgUipaNR1XTnwASLa6u4cHN0cleXIdnNFy6Zdu/UmoHuyw6 lu/ZG9Mlkpxu5xvSFLPCQUs+9KdIIzWB4JbxfZfIfn0F8hDnR35vJ+2Xn4X7SPTQ hswYCju4iU1gYdzx3NQdp7c21iv5MlJcoSaAtRmfPn8yemfi0shysq/I15ZeinK2 xcdNw4/7/I6Dw7baBfejjORE3yD/laDfmrdlzL6T2Go2X3vmfBKx904Lp3Bn8FJq McArderJxqIHSyT+vrSXE7AMuom4Vt4VZyDh4y4SrsGDi4O2tyigwQejrGp54Q9i 4uFLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduieelieefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpeffhffvufgfjghfkfggtgfgsehtqhhmtd dtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeelvd euhedtheduudelfefhgfejhfffvdeljeefgfeuiefgiefgvdehhfefuedvvdenucffohhm rghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 31 Oct 2025 09:39:46 -0400 (EDT) Date: Fri, 31 Oct 2025 13:38:44 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Nullable and non-nullable cast operators User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <9BE876E9-93BE-44C5-9C12-8E2C6FF0766F@rwec.co.uk> Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 31 October 2025 09:05:35 GMT, Alexandre Daubois wrote: >We did some research with Nicolas about deprecating casting null >instead of proposing a new `(!type)` operator=2E The idea did not make >it, and we explained why in this new section: >https://wiki=2Ephp=2Enet/rfc/nullable-not-nullable-cast-operator#alternat= ive_considereddeprecating_null_casting This highlights something that's been bugging me about this RFC: you've ca= lled the "(!type)" syntax a "non-nullable cast", but that's actually the *l= east significant difference* from existing casts=2E The *most significant d= ifference* is that it can throw a TypeError for an invalid value=2E=20 In fact I would argue that existing casts don't "accept null" at all - the= behaviour of (int)$foo can be adequately described something like this: 1=2E if $foo is already an int, return that 2=2E if $foo is a float, truncate it to an integer 3=2E if $foo is a numeric string, return the integer equivalent 4=2E if $foo begins with a numeric string, return the integer equivalent o= f that part 5=2E else, return integer zero=20 I may have missed some other cases, but there's no explicit rule for null,= it's just falling into the "else" clause at the end=2E=20 You would get the same answer from a hypothetical "cast($foo as int defaul= t 0)", except that maybe we'd like to remove rule #4=2E What you are proposing is a new syntax that changes step 5 to "else, throw= a TypeError"=2E That might be a useful feature in some cases, but it's not= hing to do with the title of the RFC=2E Rowan Tommins [IMSoP]