Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:117218
Return-Path: <craig@craigfrancis.co.uk>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 170 invoked from network); 2 Mar 2022 14:30:25 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 2 Mar 2022 14:30:25 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 479D418054A
	for <internals@lists.php.net>; Wed,  2 Mar 2022 07:51:55 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,
	RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no
	autolearn_force=no version=3.4.2
X-Spam-ASN: AS15169 209.85.128.0/17
X-Spam-Virus: Error (Cannot connect to unix socket
	'/var/run/clamav/clamd.ctl': connect: Connection refused)
X-Envelope-From: <craig@craigfrancis.co.uk>
Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49])
	(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 <internals@lists.php.net>; Wed,  2 Mar 2022 07:51:54 -0800 (PST)
Received: by mail-lf1-f49.google.com with SMTP id 5so1606623lfz.9
        for <internals@lists.php.net>; Wed, 02 Mar 2022 07:51:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=craigfrancis.co.uk; s=default;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :cc;
        bh=yAnyKLil6YWx7oIageSiWYDnekUc0A6ZzJkxM2Z+71E=;
        b=E4klxZ84ud7w+Qg/EoOG5WsLBvZu29jtwG/RhVYaQzOh6dgqPYbKZkOzwjxt7AWxDq
         RnjjW4f/mKJFjTWCiB/QA0AP5W0CaS/UOXRBO4H9jmKLMB1ATK6su38ElW29TJCEw0le
         RmpHTUMSGVe8sEi9P387+MUmXDnAmsSodm6DE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20210112;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:cc;
        bh=yAnyKLil6YWx7oIageSiWYDnekUc0A6ZzJkxM2Z+71E=;
        b=7Qf/dBsV8M2+gRpBG7e4yk58W4KLK+58rT2D1BJbn3QX/XYn1EsqELc19xciEpZgV1
         bZI/4uhLyq3TqMI3hOlwphVMGlGllSjzMlXYVPd3Ka5QwNX2LFPwkoBoe+sqqhqILi5X
         HgmeWf1Poz9cSe391GdAuG4PvL1EiBTHTKXkTPcQpLPUv9Ozzd6OIAUSfUNXFuj1arZQ
         c659DR8Q/8MvqH9u3c6ZlWSkIRYIwUdf/NJLlRCndVx6+XYLLTil3fcdcNcO3v8cVWby
         48PjDVoSjU6eWF/netosqvgg8nx880UsXckStw87HbnQfFfOUbWtVspM6T4nTOjojgUL
         mhIg==
X-Gm-Message-State: AOAM531iHNzuGhFCiHzOTk23Rovogt6SRaDai5mZZFy4pm5shV4MppXs
	oaEyav8QaB3uDL0GZ1JWLLQSn7S4cvZlHrqp1lGt+w==
X-Google-Smtp-Source: ABdhPJym3Y5oJVB0gLLh5sztERXb7+1OUnBQn1iHQHwFpFEVPIbFKLOikDtuFzTOtWmPbSfE4RmrdPI4deSkgPQSLrA=
X-Received: by 2002:a05:6512:313a:b0:443:5f49:b6cf with SMTP id
 p26-20020a056512313a00b004435f49b6cfmr19197816lfd.472.1646236313017; Wed, 02
 Mar 2022 07:51:53 -0800 (PST)
MIME-Version: 1.0
References: <CAFv4g+Efz-V5V1uUedXpusNw6z-on=TT3kdWgC66SptSd8kB4g@mail.gmail.com>
 <CAFv4g+GDsq=w7qtSOVptEBiTTDZk2aeFCVGThVBR=0-xk=0oAA@mail.gmail.com>
 <983552d8-11f1-b5bc-fb82-148347982fda@gmx.de> <5494eaa7-2fa6-8364-9683-a2c8c9789d81@gmail.com>
 <CAC5V6gjianVuPo654_-mETYxsu0-eSo++Ez1yy81MNEcfwFq1Q@mail.gmail.com>
 <69642616-72b7-44fe-97a7-27ae03bc8fce@www.fastmail.com> <CAFv4g+F0HOgCgeUyiG06qhxQnWbVCN2aaP=a2CJT9tkbMP7kLg@mail.gmail.com>
 <7fbed755-42e2-d023-285f-39863a97f297@gmx.de> <3665C848-B4C3-4528-AEFA-02C868748AA8@cschneid.com>
 <0b5bc29d-3814-0e1d-b94a-47790019c778@gmx.de> <CAFv4g+HPm+edmgnPAGwBk=4EJxj2can--iWfgtMasrYHk6pLww@mail.gmail.com>
 <4bff3f23-a3ec-4416-f44e-1f4f5d7e0caa@gmail.com> <CAFv4g+E159xoR4hxtsay-FamCSrJN+DmodvjzYGHcd1pQFsX+Q@mail.gmail.com>
 <2d06bc12-7d7e-4a88-b823-de64642381e6@www.fastmail.com> <CAFv4g+GATfXiACNk01V-RWURgsyeN11-db+yoj0R_tGOMG-2tg@mail.gmail.com>
 <f1e4ccde-fd1f-68c9-79ad-0a3ccfc8f77a@gmx.net>
In-Reply-To: <f1e4ccde-fd1f-68c9-79ad-0a3ccfc8f77a@gmx.net>
Date: Wed, 2 Mar 2022 15:51:39 +0000
Message-ID: <CAFv4g+EqhMYbbJvKn+TSKYagMFkJud8J5aGMa3aoshy8U5gpmw@mail.gmail.com>
To: Andreas Leathley <a.leathley@gmx.net>
Cc: internals@lists.php.net
Content-Type: multipart/alternative; boundary="000000000000a77a3e05d93e42cd"
Subject: Re: [PHP-DEV] Allowing NULL for some internal functions
From: craig@craigfrancis.co.uk (Craig Francis)

--000000000000a77a3e05d93e42cd
Content-Type: text/plain; charset="UTF-8"

On Wed, 2 Mar 2022 at 14:58, Andreas Leathley <a.leathley@gmx.net> wrote:

> Comparisons with == are quite worthless



Yep, but I'm focusing on how PHP works today, and while I welcome and
encourage improvements to the language, it has to be done gracefully...
forcing strict type checking on everyone (even if it's only for null), is
only going to cause upgrade problems.


I don't think I have used == in the last 5 years, and life has gotten so
> much better because of it.
>


Yep, and I urge (not require) the developers I work with to do this... and
I don't for the kids at code club; they are just getting started, and they
are learning what a if statement is; if I add type checking as well, things
"break", they lose interest, and go off to do something else, like the
PiCar :-)


Why not write:
>
> $name = ($_POST['name'] ?? '');
>


You can, but take the frameworks I noted earlier (and in the RFC). they
don't do this because sometimes it's useful to tell the difference between
a user provided Empty String, vs not set (NULL).

There is a lot of code that uses null coercion, even little things like
`setcookie('name', $name, NULL, NULL, NULL, true)` with 4 NULL's that work
today, but will fatal error in the future.

Craig

--000000000000a77a3e05d93e42cd--