Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117699 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81494 invoked from network); 8 May 2022 19:54:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 May 2022 19:54:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5580618005C for ; Sun, 8 May 2022 14:33:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3301 81.224.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from ts201-smtpout72.ddc.teliasonera.net (ts201-smtpout72.ddc.teliasonera.net [81.236.60.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 8 May 2022 14:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telia.com; s=tssemail-202204; t=1652045598; bh=tsZmQHG9jS9vTcfCGURozavviOW3nW8kA+SdPa4Sacs=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To; b=RKK65Qf1Xj86fgAgZz6jCURQWW8FCrlWLJXafFkD7z1yvRxP9446zr29do/HeQcP8tkYp2dv3DFGkUfJtoZyDeYqWvgql8FhA17Wgr9qRG4rANcaOMgR59ojhvzQ3txz1KG6tlB/udl1tRzBFWwfYKdIq/ew0PFlukkzZAxL8Tg3mF7iCcdtQ/Q6Nc07GKpWmkqMZuem2Fae3BghNeyvFxXw0P88uw4CpAb4rJhMsJgWByKU9L800X1B3o4af7Lm28YUKojJHe0Ew1GhBs2gIOWgrGHolDmmJnkw4/H2N2kdZqycgMD2jqTtdKiIoP66tveiykZ98Tqwr42ufh2/jQ== X-RG-Rigid: 626BF458005B35E2 X-Originating-IP: [84.216.97.240] X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejgdduieduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvffgnffktefuhgdpggftfghnshhusghstghrihgsvgdpqfgfvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomhepuehjnphrnhgpnfgrrhhsshhonhcuoegsjhhorhhnrdigrdhlrghrshhsohhnsehtvghlihgrrdgtohhmqeenucggtffrrghtthgvrhhnpeduhfdttefgkefhtdevveeuvdelhfetteegveegkeefgeffheffheetkefhieetieenucfkphepkeegrddvudeirdeljedrvdegtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegludelvddrudeikedruddrgegnpdhinhgvthepkeegrddvudeirdeljedrvdegtddpmhgrihhlfhhrohhmpehukeelledtieegudejsehpnhgvrdhtvghlihgrrdgtohhmpdhnsggprhgtphhtthhopedvpdhrtghpthhtoheprghlvggtsegrlhgvtgdrphhlpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.1.4] (84.216.97.240) by ts201-smtpout72.ddc.teliasonera.net (5.8.716) (authenticated as u89906417) id 626BF458005B35E2; Sun, 8 May 2022 23:33:14 +0200 Message-ID: Date: Sun, 8 May 2022 23:33:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-GB To: Aleksander Machniak , php internals References: <5598bad8-4e1a-7638-d3aa-36b02568d1a8@alec.pl> Reply-To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= In-Reply-To: <5598bad8-4e1a-7638-d3aa-36b02568d1a8@alec.pl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] NULL Coercion Consistency From: internals@lists.php.net ("Björn Larsson via internals") Den 2022-05-08 kl. 08:52, skrev Aleksander Machniak: > On 07.05.2022 23:11, Jordan LeDoux wrote: >> What exactly would be the purpose of `?int` if this RFC was passed? To >> pass >> the value as null instead of 0? That's it? > > Yes. No change here. > >> What about `int|float`? Which one would it be coerced to? > > What happens if you pass FALSE to such an argument? int(0). The same > would happen with NULL. > >> This pretty radically changes how typing itself >> would work in existing user programs. What I'm saying is that for such a >> radical BC break you need to provide some compelling justification. > > If coercion is possible it should be done as it is done for > bool/int/float/string. Inside the function you can still trust the > variable type is as expected. The only difference is that it will not > throw an error on NULL. Right now you can still use your function > "incorrectly" and not get an error, e.g. if you pass FALSE to it (I > understand NULL might be more common). And, if you use strict_types=1 > nothing changes for you. > > I don't see this as a radical change. Definitely not more radical than > making the code to throw errors where they were not thrown before (no > matter how long the deprecation period was). So, imo the BC-break > argument is not that strong in this case. > > The consistency argument is also not that strong (but here probably more > in favor of the change) because as it was mentioned already current > behavior is consistent with some things and inconsistent with others. > > The essential question is whether we want more of "weak-typing coercion" > or not. More would mean that there's no breakage for existing code in > PHP9 (essentially only 8.1 would be "broken" (because of the deprecation > notice) so people could just skip it). No need for ugly code like "$var > ?? ''" everywhere is also a win. > It's not only ugly code ;) To make your program/application/library 8.1 compatible using that codepattern requires en effort, but brings close to zero improvement, except being 8.1 compatible. So the net effect is negative. r//Björn L