Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117661 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62375 invoked from network); 3 May 2022 12:18:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 May 2022 12:18:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 55CD0180041 for ; Tue, 3 May 2022 06:55: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=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 ; Tue, 3 May 2022 06:55:27 -0700 (PDT) Received: by mail-wr1-f50.google.com with SMTP id u3so23500495wrg.3 for ; Tue, 03 May 2022 06:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=t9GcdWFmbmVYqW9HcJoIMOwQcXtF0U1K4VVkUGRmMqg=; b=P0jqw61Qjl+2i9CFYSqVxTZ/K07wJmObBnM5CCCKwech1UJqU8Pu7WTHKPJW4QrI9R ADsCUmom05VFnZO7RYOkyWGn275ZBPxku5s8n3jnUoe8DNwL2nvUWlyz1jpP1bPDbeK7 213zBja+i0NTetxmP7PjmGoM+gMbHWarwntlD83WKY7o+DQ910npMobjb4/+5x5MULtW kuOIeFDg1BowgKMHQ4GhdcBDQTZ+spqgw35KMn7WuBRPfTasyBTBD1KD0X9Uar9Q2pdq 9NA0JtUNCPk+s1EOuUdFCUIp7NNq3kpRyCpf19Du8sFPdLSpO0aj3Wv+3LyfLbQUL2rV dIjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=t9GcdWFmbmVYqW9HcJoIMOwQcXtF0U1K4VVkUGRmMqg=; b=nY+AA+8GqIIK7eR0ieQF0TAX93HZtmlTL6esAKdTXccUZknqRhVmUM3OEV8f6ycQZ9 yTjqVSXcu77Nw5+bgF/ibczBNEqrugXRv1liQyp7aEi10j6PaKnA5Znz50uI1m3gCRnv IxkITXZtzG93HUlLRTQid+91Y31oxyNBAlSW+5PXqgwHKtyTSDzbJrtc33K+9K1NuWBs 4t82iRpqOD+yflGlhO2Rzah5+WPM8vF0xPwZo8LYFdvBlRlQlOXFIn9cjbpW38O6dTim 7x23gktfyUdZNR8kW4/HmNgIgGcoukPojehfS3gA0BB9IADCB7Dt1YTOfCu7Apu2/QEr yhAA== X-Gm-Message-State: AOAM530UhfcpQs3iRSJwhA41/i2XPSBFtxhGrBfIKmEe8RoVRObDvbqr oW7JokWzu9adIgb7Ta3YjLsXiqWt3rI= X-Google-Smtp-Source: ABdhPJwuulnlUVW7BE3S6HePpWbHb0vZvcbY4HKKiUclpcwlAnDoCksxrSTYqzv2Z0Dw5BWrgrUoIQ== X-Received: by 2002:a5d:6c6f:0:b0:20c:4d8b:c8a9 with SMTP id r15-20020a5d6c6f000000b0020c4d8bc8a9mr12509755wrz.458.1651586125689; Tue, 03 May 2022 06:55:25 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id l8-20020a7bc448000000b003942a244ed3sm1622476wmi.24.2022.05.03.06.55.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 May 2022 06:55:24 -0700 (PDT) Message-ID: Date: Tue, 3 May 2022 14:55:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-GB To: PHP internals References: <42D0A480-F262-4F72-9C4D-887762A8D800@gmail.com> <0b061f28-a087-efd3-8602-424ee03458e0@gmail.com> <7DB0A01F-04FB-420D-9025-E027E5DE02F7@craigfrancis.co.uk> <9859B3B4-091A-4311-8F68-F6C35FBC32A1@craigfrancis.co.uk> <0484c0c8-569f-7889-343d-829fb820c64d@gmail.com> <84E29842-B411-451A-94B7-B4707953DA94@craigfrancis.co.uk> In-Reply-To: <84E29842-B411-451A-94B7-B4707953DA94@craigfrancis.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] NULL Coercion Consistency From: rowan.collins@gmail.com (Rowan Tommins) On 03/05/2022 12:37, Craig Francis wrote: > But what is that benefit? I'm sorry, but I really don't see it. I started drafting a longer reply, but honestly I don't think we're getting anywhere. Every attempt to explain the benefit seems to end in one of two ways: - an endless back and forth nit-picking hypothetical situations where it might or might not be useful - an outright dismissal that "people who want it strict can go over there and use strict_types=1 and/or static analysis" To me, it's *always* about trade-offs: the *benefit* of strict checks exists for everyone, and the question is whether they want to pay the *cost* or not. As long as we can't agree on that fundamental point, there's no point continuing the discussion. > I'm going on the basis that you're ok with numbers in strings being > coerced to integers/floats (which I also see as being useful, because > you're right, most inputs are strings)... but you're not ok with NULL > being coerced (which is also common, because values aren't guaranteed > to be provided by the user, and NULL is typically the default). I will reply to this point, though, because I think it's a genuinely interesting thing to ponder. One significant difference is that not only is it often not *useful* to distinguish an input of 123 from '123', it's often not *possible*. There is literally no way for an HTTP URL or header to contain an integer, rather than a string representation of one, because it's not a binary protocol. On the other hand, you might well receive an empty string as input where you're expecting an integer. Notably, that is *not* coerced automatically to zero; the code has to explicitly decide if that should trigger distinct behaviour (such as a validation error) or be treated as a default value. Not receiving a field you expected feels very similar, so similar behaviour feels reasonable. Regards, -- Rowan Tommins [IMSoP]