Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117515 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97131 invoked from network); 11 Apr 2022 13:43:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Apr 2022 13:43:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BF6C118037E for ; Mon, 11 Apr 2022 08:14:44 -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.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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 ; Mon, 11 Apr 2022 08:14:44 -0700 (PDT) Received: by mail-yb1-f170.google.com with SMTP id i20so6895444ybj.7 for ; Mon, 11 Apr 2022 08:14:44 -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=EZTpx6kfukyVvfNlW1V5FS6rDNdnuE+FZDCkziQvs4U=; b=FCNX8v8N0K/+5tySiR21k6idOpZeHuvjcIhySu0pcjGTmkzTipdlKRGWMWULe6DcxU qivhr4qQO+289nny356mnhZcI+fTOl5STuaiSF7ESvKUjNTCr9CUE37PhCIBwxkkKMxt ZySfonkR4oh2A89oeNj43PwmuRI70+7TjjtbsPs0L8whO8pjc+OgVIQ862zt78xueqci uGkk+IZVjWytwKnOBGeDiHXpldfIsgaeQHz4o3ApNN5C1fFszc9BrvSZ1/TStYjTqgPZ I2S0XgqE8uWKvVAzHRNm6OY9MOek8jmyCT8mtEmbm4xCET/Jo8O1WmbAXyLgPT1v9JlL ARQA== 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=EZTpx6kfukyVvfNlW1V5FS6rDNdnuE+FZDCkziQvs4U=; b=DD2IXFFLKCIeGSRvcuTZO6rnj1wUrGcbvFvuHTfnHwurp/QQqTncu5Aw5ItTGZ4auY s0Awt1CzdyqVnmpXzgLvvmMPvGry0FidrG6D68pk+KmF4/2JpXuVzhiyUwIh7OegAS/1 Zrfo5iE6hORoqS/FJ5EnhZ/Yr7CAypONg1bLQFSxeTndi1saOJn49UMP0Snh/K51mf8v fRukMoM3QGUZTlrXRe9oONta88kCEjd70l87igjOaSrE8aB1GQ6fgw3he4hqBxwCuOMD CXwjPaCB4XNa+1PLCd3QDjxTAm4MTeOy+rRx54oxh6X1uibnv0Iur8mVvXWK+z7x++PI TeoA== X-Gm-Message-State: AOAM533wqG3bTqg1s7UEv9hEJpml85/48Ei4gdtUJPN1q2UPB5rvoFbI IkkwR6UgemKpKo3Kwnxs9KSNyiRn0SVnZnuBFJE= X-Google-Smtp-Source: ABdhPJzu7PHYd9r8FQ64I8PomNMxTytSzzF/5yux3AKKPoeFHSKFNi18SYW4JrgriLMg1KsbP0OdhJzuULC7NK6+chE= X-Received: by 2002:a05:6902:708:b0:63d:dcb0:c73e with SMTP id k8-20020a056902070800b0063ddcb0c73emr26083643ybt.231.1649690083833; Mon, 11 Apr 2022 08:14:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 11 Apr 2022 16:14:32 +0100 Message-ID: To: Craig Francis Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006fb93305dc6267e4" Subject: Re: [PHP-DEV] NULL Coercion Consistency From: george.banyard@gmail.com ("G. P. B.") --0000000000006fb93305dc6267e4 Content-Type: text/plain; charset="UTF-8" On Fri, 8 Apr 2022 at 18:35, Craig Francis wrote: > Hi, > > I've written a new draft RFC to address the NULL coercion problems: > > https://wiki.php.net/rfc/null_coercion_consistency The statement that: > 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. Even the competing RFC from Zend et al [1] proposed this behaviour > A new set of coercion rules will apply to both user-land type hints and > internal type hints. The guiding principals behind these new rules are: > > 1. If the type of the value is an exact match to the type requested by > the hint - allow. > 2. If the value can be coerced to the type requested by the hint > without data loss and without creation of likely unintended data - allow. > 3. In all other cases - reject. > > And later to describe the internal function changes: > This RFC proposes to bring the rule-set described in the last section to > internal functions as well, through updates to the zend_parse_parameters() > function. > There was obviously the caveat about NULL being coerced for internals functions, but other than usage, another reasons stated: > However, since this requires substantial auditing of internal functions - > especially ones that have default values but don't explicitly declare > themselves as accepting NULLs - it's outside the scope of this RFC and > will be revisited for 7.1. Note that if the > https://wiki.php.net/rfc/nullable_types > is accepted it will further > reduce this discrepancy, by allowing user-land functions and internal > functions the same level of granularity in terms of accepting or rejecting > NULL values for function arguments. > This auditing was to a large extent performed in PHP 8.0 with the introduction of the stubs. You can disagree with some of it, but this again brings us back to amending functions to have nullable arguments, not a blanket change. I appreciate some want to force strict type checking on everyone, but I > want to make sure we have this properly documented, with names, and > explanations. > > Breaking changes should be justified - if they aren't, they only > make upgrading difficult and frustrating (bad for security). > The breaking change was justified and explained, and voted unanimously in favour with 46 votes. The burden of justification is now on your end. Moreover, the breaking change has also been announced with ample time to fix the issues until the next major version. As with the previous one, this RFC is getting a strong no from my end, changing the type system into a broken and inconsistent way, and reversing a unanimously voted RFC needs strong justification. Best, George Peter Banyard [1] https://wiki.php.net/rfc/coercive_sth --0000000000006fb93305dc6267e4--