Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117211 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88455 invoked from network); 2 Mar 2022 13:36:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2022 13:36:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F0FE918054B for ; Wed, 2 Mar 2022 06:58:27 -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_H5,RCVD_IN_MSPIKE_WL,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.19]) (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 06:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1646233106; bh=rVlbYGcghDlhKCV0qoxB4gNnzObsMjsydu+/lS0VdKA=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=UwSrVsA6drbd8UaNShgjzAFyVi/Gm+Jp3+O49DJYo5VcHHvX2vdXLOWr1if9uiMS/ ixgVg5IGZ5KDY6TQXiuDO02FWKE7y5Wp4NbuzveYLclcGQaG/ZXnRHDj3jooIboII/ cpFdrqOgVdMp2SQXYK4UfBSwI9tziEPm6Rb4166g= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MmlXA-1o5fDL3yNy-00jmhO for ; Wed, 02 Mar 2022 15:58:25 +0100 Message-ID: Date: Wed, 2 Mar 2022 15:58:25 +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: 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> <2d06bc12-7d7e-4a88-b823-de64642381e6@www.fastmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:vK3EK/POeGK8IK1RWlNr9U2Du6lmMkcR8jyJxQCl3uEsrQbf7lb W0mODXF5B1cry3/vGp6xBX4sx0p5lPlJhNsphww2U8Gf3yT/2Yr+eYn1p+yHYL4S8LeuN5H zwVOC8QVNd3lHsmYk5mbt55ACnjuF0YjHR51RHRoSrqividXlibM4L6wc5PARyjekOgI+jH 2VLScqedZCCpVijMiYoNg== X-UI-Out-Filterresults: notjunk:1;V03:K0:PFDbGxuxb4k=:v5OFfxL8iJqVhxQG/SyOnu mQ9qCMy8SA4PeS33+Iv8wBdTQukPKyZjiwvdXrOvqzi4A2iK6HbS6/vkNbFAeb2EtfI50IeFk OORlN6ygvFi6gluV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: a.leathley@gmx.net (Andreas Leathley) On 02.03.22 15:27, Craig Francis wrote: > On Wed, 2 Mar 2022 at 14:17, Larry Garfield wro= te: > >> Null is not an empty string. Null is not a string. Null is not 0. Nu= ll >> is not an integer. > > So what should this do? > > $name =3D ($_POST['name'] ?? NULL); > > var_dump($name =3D=3D ''); > > Is that now going to be false? > Comparisons with =3D=3D are quite worthless, except when comparing objects= , as =3D=3D has so many caveats for when it returns true because of weird rules about what should be considered equal or not for legacy reasons. I don't think I have used =3D=3D in the last 5 years, and life has gotten so much better because of it. Why not write: $name =3D ($_POST['name'] ?? ''); Then you know 100% that $name does not contain null. It might not be a string, but it cannot be null. You can still not safely pass it to something like htmlentities or str_starts_with, because $name could be an array. And I think that is the reason why the current deprecation and eventual removal makes sense - it highlights missing logic that can easily lead to errors. If the problem is not null, then it might be that you have another unexpected type like an array, because the value was not properly checked. Putting strval around such code (as one possibility to resolve it) at least improves the code, in that we then have a clear type for the variable, removing some room for errors and bugs= .