Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117523 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41511 invoked from network); 13 Apr 2022 12:43:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Apr 2022 12:43:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2786A1804AB for ; Wed, 13 Apr 2022 07:15:27 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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, 13 Apr 2022 07:15:26 -0700 (PDT) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-2ec0bb4b715so23902517b3.5 for ; Wed, 13 Apr 2022 07:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFHDW5o8rbmUR4+jTCDe+rUMivAD8sWHZteVzQkSBtw=; b=iNJSkz47Kw2NS9LCT2Q7y4N3/fCyd5fJZ7nEtVFpUw+4aofZRS80v8Vbu7LU6U6qWv ptssQw08w5mloBHh5A1DFnoFVdQZlm93y7/HqTQxE/86DAbwCZWTZKB7TAAtrxxaRN02 3pwWBrISsFwIF75f836F1AAVibFYNKuLH+gAZtF1D6ElIft/AtniClVwitVCCAau+fmi rasJxIIOCrAYENo8z7/TR2PdntUINHs9vN7RvOQMlrCE/nQJ14yW8Mv+OUUzZwOMQ8VU z+MSHriSRjGscwUXogNO5nRP7HCB6mhKmdtYehmT4fGIu4c5BBPVmiw/MxH0D1jB2EDv l1Zw== 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=cFHDW5o8rbmUR4+jTCDe+rUMivAD8sWHZteVzQkSBtw=; b=oLgUfe+HmGJVgPM0nuNOwPpKZW+VCGgi6LyqAFKXevdoB/BtUn/UECg4AeeDyeUaHv o0YmXqxpfaNUMKfpGyvgDcPWj7VZ3jMsnVdIXqY2IaQmH0M9wsY+pdE+PQNFnGLG9qzq ggb+jlezDofPNhtt2KWeyWUwJ6upbEfpFyONz0At5Eq0RegcaiPataU2tiiorVKOWbTN YfqpWHP9R7wLbw8hY0+r6xfVkiOBWZ58qrk6WkDtjzZ40WGUcJnOQR2Z9m8eQ1R5yWaT QRWEvyubmPU3/F/mmB6cLmfPbSiBV+Dv3ViqozIcPr3H03Qtc/WZa+pSP5OfqUWYq7Eh G3lg== X-Gm-Message-State: AOAM530Qwwk66P6JmEaKPAKA0NLCaDlYswtqhFoubT/+ovLQGyfSefyt eSe+selmtbyw4AW5dYf/76Rpkne9idJ2W8xxuU9tI5yyxphAeg== X-Google-Smtp-Source: ABdhPJwlpwPfGV/L5bkKsCu2gskgxBqWDQY08Q0nA6tCNWbTQiW8GQb0gbnyVw2YzoCu6vz1xliBxDkcl+/0/JFiwHk= X-Received: by 2002:a81:83d1:0:b0:2eb:f0ca:d08a with SMTP id t200-20020a8183d1000000b002ebf0cad08amr18664613ywf.120.1649859326044; Wed, 13 Apr 2022 07:15:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 13 Apr 2022 15:15:14 +0100 Message-ID: To: Craig Francis Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000000eecf005dc89cf00" Subject: Re: [PHP-DEV] NULL Coercion Consistency From: george.banyard@gmail.com ("G. P. B.") --0000000000000eecf005dc89cf00 Content-Type: text/plain; charset="UTF-8" On Mon, 11 Apr 2022 at 19:22, Craig Francis wrote: > On Mon, 11 Apr 2022 at 16:14, G. P. B. wrote: > >> But the implementation caused a Type Error when coercing NULL for >>> everyone (even when not using *strict_types=1*), this seems more of an >>> over-sight >>> >> is utterly wrong and was a conscious design choice based on the widely >> accepted view that nullable by default like Java is a mistake and defeats >> the purpose. >> > > > Bit hash... anyway, I've replaced that paragraph (it wasn't clear enough), > I just wanted to note how developers not using `strict_types=1` would see > it as an over-sight that coercion works for string/int/float/bool but not > null (despite what the documentation says), and how it's introduced a type > check (that they didn't ask for). > > I assume you're using `strict_types=1`, and will be unaffected by this, so > with all due respect, I'm not considering how you view or use NULL, nor do > I care what Java does, I'm simply focused on how most developers use NULL > in PHP. > If I indeed exclusively used strict_types I wouldn't care, but I don't because IMHO strict_types were a mistake and are harmful and induce some self inflicted problems. I've spent a large amount of time making coercive typing mode more sensible and aligning the behaviour as close to reasonably possible with strict_types so that the possibility of dropping strict_types all together wouldn't be outrageous. I've written about this elsewhere and on this list already but main points are located here: https://github.com/Girgias/unify-typing-modes-rfc Userland scalar types, however they would have been introduced, did not include coercion from NULL for *very* good reasons. Wanting to change this behaviour needs more justification than a paragraph in docs, as the docs should reflect the reality of the implementation. The second aspect is the general consensus that internals and userland should behave identically. Which is why the deprecation is here in the first place, to align internal behaviour with the accepted *better* design choice of userland. Your RFC is going against these two pillars. Moreover, the fact that we are deprecating this and not just changing the behaviour from one version to another is that we do recognize PHP developers use NULL in this way, and we are giving them advance notice of the change. Also a deprecation notice should, IMHO, never be promoted to an exception. This is maybe something we need to get better at teaching end users so that they don't pressure library maintainers (or themselves) to fix all of them when they still have a couple of years. Be that either on the php.net docs or elsewhere, to teach end users to either not do this, or at least exclude the vendor directory from their error handler. However, and I cannot stress this enough, we cannot just stop using this tool available to us to steer the language into being better. Because then the other two choices are doing hard breaks with no notice in a major version, or not breaking anything. Both things which are unreasonable to expect. There are behaviours of PHP that will probably never be "fixable", but this should not prevent us from improving the aspects we can. And if we only focused on how developers use PHP we would still have register globals, magic quotes, etc. Clearly it seems you won't listen to why these changes were made and want to reverse course, therefore good luck convincing enough people to accept such an RFC. I think I've said all there is to say and won't interact further with any such proposals. Regards, George P. Banyard --0000000000000eecf005dc89cf00--