Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128960 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 A04B61A00BC for ; Sat, 25 Oct 2025 07:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761378869; bh=PDJmVQPG7f+qR7bqxg8A/CRc6DBRbJcE0GVFFyiltrw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=heuGyBjZlF36D4LxirTHhy3saXL0GCTh2V6FiWRcix7vmqroLwZPwe9D6FeQ0Ugeu B7ngoOmWHcti+l7AKCFTbStJYTOlUbxMkXf6pxXoe6zmekcEuU13QjIqFPfqLOQJSC EIun+JBVXk0E5gxwv7a7IovIXT4zGQr5jYEXwr6D1IoBUSHea4GZNa29jXviMeNQik WEyUHkIGrnq+c8KbOZI10r0tNMVZ0tUXLjmSsKyARfd+/GzOoVEOc8SJnGj+KqU3XW phMUfFa5430RrUTzh2VFshTO+kxxuSUwiEzWnA7uEJKk4RneFNevdWcRoNTdn7wlQk Z0Usxb3JRvEtA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5416418006A for ; Sat, 25 Oct 2025 07:54:28 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (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, 25 Oct 2025 07:54:27 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 498C91D002A3 for ; Sat, 25 Oct 2025 03:54:22 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Sat, 25 Oct 2025 03:54:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1761378862; x=1761465262; bh=PDJmVQPG7f +qR7bqxg8A/CRc6DBRbJcE0GVFFyiltrw=; b=pR/PwgPedpk8ecqT/Tf8e4CyX9 vrHLdt/iCfasSfzgnzINKOynsyxen2FDYMnUNEOBCBGKJiIR5TZT0J6FKl7xOOtn FVJydP0XTzKRMICqtl0H0HSf0AEvx+APztYoKO9iAfDVzV/G9bYshlHI5YZO+sHK C0IL8hW6icYMW0g+g4FjL9HRgg3NBCTg29M1Mc0Jo50Zi+vSL0ClVb4T3gqqerZk 1KX6UAx3axUsSaTPyEXuWN8nhVLnQzYDK1VDcYTQt4yoGwfaN/4o3Z14WPCOSWGU zfm9Mvz31w1RmYqzVCObaZ1TCoeuE25xjFznT3o16vkfjKFsZXkkbtQdZ9rQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; t= 1761378862; x=1761465262; bh=PDJmVQPG7f+qR7bqxg8A/CRc6DBRbJcE0GV FFyiltrw=; b=qIyCZkvCrxyJ0G3VznnfIPzW0ducnIJPWblt2SlB+QJXv4EuNQd PrIvYq8Bh+lX1y4WSG484PXl3VKj3Y149mFvo4vl2tcb+vT3Sd4nUtv8Kq1v4IYE h0idFnfodJmKaJpNDyx4lajZgiDjOJTXw0OCnlHKSqyhywdFEPtx4xBO7w4qSp5h 5RkM43etVaQEvxhJuuWXdOw4H7nFAUR2tO3yjYZMtcttkPkooWSTODgD15cWuyxS u2n+Bv799A/TSDnrhPhFZi4CR5vz6bnh65kntgpbXsdrtTV742kGbMvd065N4S/w fe4DRwjqRa/T0KKQONmSbEHK8LhIwusG8xw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduheduieejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefoggffhffvkfgjfhfutgesrgdtreerre dtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggu rdgtohguvghsqeenucggtffrrghtthgvrhhnpeelkeehtdfgfefhleeilefggeeihfekvd elfeejtdfflefhheehfffgudetuddutdenucffohhmrghinhepphhhphdrnhgvthenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsoh htthhlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id BDD421820054; Sat, 25 Oct 2025 03:54:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: A9h1dLxFSJH3 Date: Sat, 25 Oct 2025 09:54:01 +0200 To: internals@lists.php.net Message-ID: <10553948-3c42-4aac-b20b-dd2d82c83057@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Nullable and non-nullable cast operators Content-Type: multipart/alternative; boundary=12cfb21bb0ee4dcb9294b61797cac6d0 From: rob@bottled.codes ("Rob Landers") --12cfb21bb0ee4dcb9294b61797cac6d0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Oct 25, 2025, at 09:40, Aleksander Machniak wrote: > On 24.10.2025 09:07, Alexandre Daubois wrote: > > Please find the details here: > > https://wiki.php.net/rfc/nullable-not-nullable-cast-operator > I see two issues here, and I'm not sure how I feel about them. >=20 > 1. The new operators not only change how NULL is handled, but also add=20 > validation rules. So, their name should be changed, maybe "nullable=20 > validating cast". I guess "strict" word would not work as they aren't=20 > really strict. >=20 > 2. They are supposed to have behavior in line with function arguments,=20 > but they don't react to strict_types. The RFC says: "using *weak mode function parameter coercion* (stricter t= han traditional casts)." (emphasis not mine) If it were to act like stri= ct-mode arguments, it=E2=80=99d be more like a type-check than a cast. T= he entire point of a cast is to "turn one type into another" and strict = mode doesn=E2=80=99t do that at all. Parameter coercion in non-strict mo= de (I hesitate to call it "weak mode" because in some ways it=E2=80=99s = stronger than strict mode) is a well-documented behaviour, and if you=E2= =80=99re used to working with it, this is a welcome addition, IMHO. =E2=80=94 Rob --12cfb21bb0ee4dcb9294b61797cac6d0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Sat, Oct 25, 2025, at 09:40, Aleksander Machniak wr= ote:
On 24.10.2= 025 09:07, Alexandre Daubois wrote:
> Please find the detai= ls here:
I see two issues here, and I'm not sure= how I feel about them.

1. The new operators no= t only change how NULL is handled, but also add 
validati= on rules. So, their name should be changed, maybe "nullable 
<= div>validating cast". I guess "strict" word would not work as they aren'= t 
really strict.

2. They are su= pposed to have behavior in line with function arguments, 
but they don't react to strict_types.

=
The RFC says: "using weak mode function parameter coercion (stricter than tra= ditional casts)." (emphasis not mine) If it were to act like strict-mode= arguments, it=E2=80=99d be more like a type-check than a cast. The enti= re point of a cast is to "turn one type into another" and strict mode do= esn=E2=80=99t do that at all. Parameter coercion in non-strict mode (I h= esitate to call it "weak mode" because in some ways it=E2=80=99s stronge= r than strict mode) is a well-documented behaviour, and if you=E2=80=99r= e used to working with it, this is a welcome addition, IMHO.
<= /div>

=E2=80=94 Rob
<= /html> --12cfb21bb0ee4dcb9294b61797cac6d0--