Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117526 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89471 invoked from network); 14 Apr 2022 05:59:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2022 05:59:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ED78A1804CF for ; Thu, 14 Apr 2022 00:31:46 -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, RCVD_IN_DNSWL_NONE,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-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 ; Thu, 14 Apr 2022 00:31:46 -0700 (PDT) Received: by mail-pl1-f176.google.com with SMTP id 12so3952758pll.12 for ; Thu, 14 Apr 2022 00:31:46 -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:content-transfer-encoding; bh=FuxkX6mKY2fNc76GgE8Yd7wiLTWxKBqu4KYP7hnBnU4=; b=J5GfM9QCmdxl81znjpehd1Ru9jNCykE+uwxfpqlGV5kp/ih9Mq5Zq+AI7mCrWDiVjQ 4yHX6+ZQbsTm/KwZXT85M2uAfQyV/vACU4ZHtGGFYPFuh8phwqujrc3vPjo8qElOyw2L osnwW3EpCmfveld8e0QTu6wRszVtAT3CzQvuppe1EC/6DHbM7Bs51O2uEsoqZ19qpt18 P1m5etq+rKwG4Wzwjm8zdsJi0wNl16jKbcfWYtbO9uzWaZuQuHwruvLk00TAw94a0BKO BFMU9tX5zRHoRfVRCSfdeCP9FP2ZiOk6B9MLGVWUTj46XAXqLfuiRL8rXNPP5BmjDv7w xpzQ== 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:content-transfer-encoding; bh=FuxkX6mKY2fNc76GgE8Yd7wiLTWxKBqu4KYP7hnBnU4=; b=guVHIkA0Vov1LYT8CiJ4QGdfF/DCdRZhT8q8tRLSUxdC7lqAzR6YIEdbcP5Szaa76F AspfxFXLrr9xIR18BFtZ//gTk+lsxcouOXuwUZK5bj1spR3ZsmAe2xWA+TZif8UD29Yy HkOU88c03Kd2s9ksh79oqDJIyZGA0/KkKkVcL0qKoRPpO04jVlTHU3yqc8bEaUV+46Jb hS0ZaeocfLE9C8dCOg8Yl4nNsRDkfnnNUi95BlUC6Fudrv/SyORrw5eH5Iu/VttC+H9z dqrst/xQCHrVUsEcPymoZhFTuy4HVOixGY806+5Hw0Uh52iQ6WsPmVYbDr8kH9JE7poR YJSQ== X-Gm-Message-State: AOAM5304nnq8YCtiUw2EQ/ffarKT6CF6cVpEDHu0mjTD273FYVaODPz5 kAUHR3XzLT8CiBLewStebU4bDUHpvg0cQN8BTG3QCCdt3YBssg== X-Google-Smtp-Source: ABdhPJyXw419dM2dMbdNL6rAi1P7GzC5qmVAc51pMQAdYAxWOSUonsKOgJJF1YgGBx2TF5aVvIncACVYzDipEu92ZZI= X-Received: by 2002:a17:90a:e7d2:b0:1c7:b410:ccfc with SMTP id kb18-20020a17090ae7d200b001c7b410ccfcmr2285344pjb.209.1649921505251; Thu, 14 Apr 2022 00:31:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 14 Apr 2022 09:31:34 +0200 Message-ID: To: Craig Francis Cc: "G. P. B." , PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] NULL Coercion Consistency From: landers.robert@gmail.com (Robert Landers) On Wed, Apr 13, 2022 at 9:45 PM Craig Francis wr= ote: > > https://wiki.php.net/rfc/null_coercion_consistency > > On Wed, 13 Apr 2022 at 15:15, G. P. B. wrote: > > > I've spent a large amount of time making coercive typing mode more > > sensible and aligning the behaviour as close to reasonably possible wit= h > > strict_types so that the possibility of dropping strict_types all toget= her > > wouldn't be outrageous. > > I've written about this elsewhere and on this list already but main poi= nts > > are located here: https://github.com/Girgias/unify-typing-modes-rfc > > > > > Thank you George, I do appreciate your work on this, I agree with pretty > much everything you have written, and I really do want PHP to move in tha= t > direction. > > The *only* thing I disagree with is NULL coercion, because it has worked > perfectly well for years, and is used so often. > > > > 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 paragr= aph > > in docs, as the docs should reflect the reality of the implementation. > > > > > Some people see NULL as an invalid value, which can sometimes be useful i= n > a `strict_types=3D1` environment, but that's the only "good reason" I can > find... it's why I changed my mind about making some parameters nullable, > and took a different approach with this RFC. > > But most developers do not use NULL like that, and that's why it's passed > so often to the ~335 function parameters I've noted (most of them are on > the list because they realistically receive user values, which can be NUL= L > in most frameworks). > > > > The second aspect is the general consensus that internals and userland > > should behave identically. > > > > > Yep, they really should... it's why I said we "Must keep the spirit of th= e > original RFC, and keep user-defined and internal functions consistent". > > > > 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 excepti= on. > > > > > Unfortunately deprecation notices are being ignored (as noted in my RFC, > with examples on how); and there is the intention to use Type Error > Exceptions in 9.0 (the thing I'm trying to avoid). > > I'm approaching this from a security point of view - the last thing I wan= t > to do in ~5 years is auditing code/systems where they have stuck with 8.x > because it's too hard to upgrade. > > > > There are behaviours of PHP that will probably never be "fixable", but th= is > > 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. > > > > > I want the language to be better as well, and I was *very* glad to see th= e > back of Register Globals and Magic Quotes (I know they were a pain to > remove, but it was well justified, as they caused so many problems). > > > > 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 acce= pt > > such an RFC. > > > > > I have been listening/reading (it's why I've taken about 2 hours to read > what you have written, and reply). I have also been discussing this with > different people (on and off list)... unlike the original RFC discussion, > where it was only Craig Duncan that mentioned this issue: > > https://externals.io/message/112327#112531 > > And it's because I've been listening to people that I changed my mind, an= d > created this new RFC (as noted above). > > > > I think I've said all there is to say and won't interact further with any > > such proposals. > > > > > That's a shame, as I'd like to discuss solutions to this problem you woul= d > be happy with. > > Craig I don't have a vote, so my opinion only goes so far. But here's my 2=C2=A2. > I see null as a real type This confuses me. I see "false" and "true" becoming their own types, so what is a boolean? The language currently has no way to express aliases of types, otherwise I'd say a boolean is an alias "true|false" but it doesn't. What happens if a function returns the "false" type and I pass it to a function that only allows "bool"? I expect it to work. So naturally, there is some coercion in there as well, and it would be great if null got the same treatment where old codebases benefit without taking away the advantage for newer codebases. I see this RFC as a balance in that regard, because real life is messy. I really hope it passes and good luck! Robert Landers Software Engineer Utrecht NL