Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129943 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 51D8E1A00BC for ; Tue, 27 Jan 2026 15:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769527430; bh=KXzN/I7yzwDI8EUDNMAOyet/xIutf6GaIgmIsYysPFU=; h=Date:Subject:To:References:From:In-Reply-To:From; b=bRpE+rszv4R/M0iawU/wd2ahRw9XuGvdQU2H7CD9Ovb1WGH0Bm/iNR5IQwCQKVXEW RNMyHhwVX69hRnEFStTIfh5Dce/thnEjwXkoe1Ry6Y2eG5//d3/m/YGwosAf6tSncA q/oC6gK7Ek6RtQ7VvWjIQgkwFEcq9RzZRThe/7yFB3NnKKBTkxRuu7/BSfW/59zWsB ZuXXAg2hWtNjEPHa93Gaqcf+plDyiUU1NWrrhu0tEQxCtvgq46CGEP3tAsZzWUq2Rn cBZmWrcl+HFAm0TcaaUTAaVJXnR6uRBFgWqPYFVBPWh+npo2IeAiNXXRYqenamVyq+ BaCZvHotCftHQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4EBB0180086 for ; Tue, 27 Jan 2026 15:23:47 +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.9 required=5.0 tests=BAYES_20,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-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 ; Tue, 27 Jan 2026 15:23:45 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id DC1307A0139 for ; Tue, 27 Jan 2026 10:23:39 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Tue, 27 Jan 2026 10:23:39 -0500 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=fm2; t=1769527419; x=1769613819; bh=KnHg3DGH4xkccxNtHz9y27xs8Wvh3vd3U28PGV9rZ84=; b= SYQ+jqDMWGAGb1hAj8F4LI7eKWf6hINn3OdiYFl5vdS7iu/NRYtbnBgsX2MSafH0 Sn7YChMucuIh1u+b9fJyXXoBs4PZw18u7s92jXVCB0936Vj0FZ1O2revhyfEQMs0 6DiO1q20Fm95fnM/Awx1JruIOFr/tXfZnA0Agxl5ZazwM57CGxxHU6rVmyPlqShZ Nl1iwTM8ujoAU72T71GPOT8DAMGSjGuUYHDNlqvmJZH6iEkbUVnYxPJWo2hPi76Z iuMks+ohSwzTWJic5IWEg2S+Ar/qyLsB7mEdsoe+skuQK/tfhHLUUGDsuzq9IeZe BEYv+HUAhRuCx+xyqbwQgA== 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=fm2; t=1769527419; x=1769613819; bh=K nHg3DGH4xkccxNtHz9y27xs8Wvh3vd3U28PGV9rZ84=; b=S8cPAM/9ATpXM71i9 E+3gPWjCH9Z7j4leHbjnBDPCLyR7nxbgKf5RuMfZZqUSbZJJ2Ctl26NtViz7LnGj aQU7fj9cn0d5X6mc3FGlazxdODF7/xHtS80W5uxTEAKxcLajJ0loIPrIX70GvKWK 8VabQIkcnDYBcK1hr89IygFbD95eBefU3Ex9QpRnx1fWmRMpsf6taX8OtGLxMluZ zuSpOvp4QlweyCf+AZvd8B6jruy8M2iPG1pPBA4g5b7YYPb+RXMDOzhVaDlYs46A 7s8gS0TBBEHa2Vk5Cup6z/dQbrm425SKcjco37MVimnG7S6vwmP3f8ZtxdGnv/Eh SvR5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduiedtkeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeejge fgheejveeklefhudfgffetveegjeehtefgteeuieehgeevtdehlefhhfeuueenucffohhm rghinhepfehvgehlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgt phhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlh hssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 27 Jan 2026 10:23:39 -0500 (EST) Message-ID: <007ae3ff-2b9c-46da-9513-0c147958b806@rwec.co.uk> Date: Tue, 27 Jan 2026 15:23:37 +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] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode To: internals@lists.php.net References: <411b1964-eacd-475f-a9f5-2a954b6d30df@app.fastmail.com> Content-Language: en-GB In-Reply-To: <411b1964-eacd-475f-a9f5-2a954b6d30df@app.fastmail.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/01/2026 12:13, Rob Landers wrote: > > I kinda like this idea, but it would be nice to follow the same rules > we have with function calls, thus > > int|null $var = "123test"; (https://3v4l.org/C0uaK/rfc#vgit.master) This comes back to my point about the two-part definition. You are suggesting that "int|null" should only affect the *input interpretation*: "allow null as a valid input, but error on invalid input". Lynn is suggesting "int|null" should also affect the *output behaviour*: "use null as the default output for any invalid input". This is why I keep thinking about a *family* of cast operations, where the *input interpretation* is standardised, but the *output behaviour* is selectable by the user. My current best thought is a generic-style syntax: must_cast( 'hello' ) // TypeError try_cast( 'hello', 0 ) // int(0) can_cast( 'hello' ) // bool(false) must_cast( null ) // TypeError try_cast( null, 0 ) // int(0) can_cast( null ) // bool(false) must_cast( 'hello' ) // TypeError try_cast( 'hello', null ) // null can_cast( 'hello' ) // bool(false) must_cast( null ) // null try_cast( null, null ) // null can_cast( null ) // bool(true) -- Rowan Tommins [IMSoP]