Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117217 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97295 invoked from network); 2 Mar 2022 13:59:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2022 13:59:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 06FFC180546 for ; Wed, 2 Mar 2022 07:21:12 -0800 (PST) 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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 2 Mar 2022 07:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1646234469; bh=Ewb8krrWq611mlBJB4DXLvzh+CeJSLuP/HRwD5qS7QQ=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=J9HCc2kazPTMATpWNiO2+L+CZC0+YuMFmUDoib2LtpaR788Rkp/Hub3T51jFWFmsp TpjDd8SqolCjrKegR9TzHYCfqKRquQ7p57N6ECa4M4OQiFMx6/MrmT8tX4A2w8AxcP k7apUaEKjg/GwB3sc3J+1bteAjmpkVRVwjIgK4c8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N5mKP-1oHZde1wjr-017Aip; Wed, 02 Mar 2022 16:21:09 +0100 Message-ID: <96d2babf-63d5-9fdb-8b95-a117247a9d21@gmx.net> Date: Wed, 2 Mar 2022 16:21:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: Craig Francis Cc: internals@lists.php.net References: <983552d8-11f1-b5bc-fb82-148347982fda@gmx.de> <5494eaa7-2fa6-8364-9683-a2c8c9789d81@gmail.com> <69642616-72b7-44fe-97a7-27ae03bc8fce@www.fastmail.com> <7fbed755-42e2-d023-285f-39863a97f297@gmx.de> <3665C848-B4C3-4528-AEFA-02C868748AA8@cschneid.com> <0b5bc29d-3814-0e1d-b94a-47790019c778@gmx.de> <4bff3f23-a3ec-4416-f44e-1f4f5d7e0caa@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:PSdChvTVLbe8GYfZOK2meBDugx1fdfd9B6piu1CH2VUOfAxdeL4 KzBebKVbjaDqqpiu+im5Y79/txmQrDzehihxePMdW1mQvffBjupZSaTcAYE9+Dk+EQyMAbZ EX0n8ODCXYSMtTYr31LedVIDgrl4lg66Dnquokz42rBTdOfuZ50Prc57NSZCLGk8/87bmKE E9JTAR12vMjN3XbrBGJvA== X-UI-Out-Filterresults: notjunk:1;V03:K0:vnWzZcXEYuY=:5/R4aWw1g1QVFTag4yrq7r w6sKw9JAPLLSyWkUos5sYMtOu6DEIQgF6hDVlsFxSJeo46iVmSKaGk6hDVFn5tCGeCjF4Kggd JuZTPUEXAajxHuTk4S4/nL2bkohtpXBZ6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) On 02.03.22 16:00, Craig Francis wrote: > I'll note that converting from NULL is used all the time, and is well > defined: > >> https://www.php.net/manual/en/language.types.string.php >> "null is always converted to an empty string." >> >> https://www.php.net/manual/en/language.types.integer.php >> "null is always converted to zero (0)." >> >> https://www.php.net/manual/en/language.types.float.php >> "For values of other types, the conversion is performed by converting >> the value to int first and then to float" >> >> https://www.php.net/manual/en/language.types.boolean.php >> "When converting to bool, the following values are considered false >> [...] the special type NULL" > This is the behavior for explicit type casting (strval) and the implicit casting when using a variable in a string context, like echo or print. This is basically just a base necessity - for example an array is converted to "Array". All information about the array is lost, except that the string is now called "Array". So would you say something like htmlentities should also accept array values and automatically convert it to the string "Array"? It is used all the time with echo and print, and it is well defined, yet it is still not a good idea. For strval and for echo it makes sense to convert an array to "Array" (barely, to end up with a somewhat useable string), but for parameter types it does not make sense. The same goes, in my opinion, for null. > It really depends on your code base... Laravel,=C2=A0Symfony,=C2=A0CakeP= HP, > CodeIgniter (the frameworks I'm familiar with) all return NULL for > missing GET/POST/COOKIE values, and that is a useful feature... but > when the developer naively passes that to any one of those listed > parameters, you will get a deprecation message in 8.1, and a Type > Error in the future... and finding all of these is incredibly hard. These frameworks change their types and signatures quite often - much more than PHP ever does. One Symfony project of mine that is now 7 years old has had crazy changes, both in types, signatures, directory structure, etc., yet people adapted and the changes were for the better. Compared to the changes produced by frameworks this deprecation about string values and null seems much smaller to me. And I do think it is important that coercions in the language become less frequent rather than more frequent, also because the language does have a certain "role model" effect. From 7.0 until 8.1 it was a legacy effect that converted null to an empty string, and only for internal functions, but with your proposal it would be an intentional decision to start treating null and scalar types more interchangeably.