Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117505 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34817 invoked from network); 9 Apr 2022 07:58:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Apr 2022 07:58:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 95800180380 for ; Sat, 9 Apr 2022 02:29:56 -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,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-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 ; Sat, 9 Apr 2022 02:29:56 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id h11so14260482ljb.2 for ; Sat, 09 Apr 2022 02:29:55 -0700 (PDT) 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=+YRDymGBWr25XFhfXR1fZ1bYzLQekf5JtaB4JC+47fc=; b=erEwFYjIDGMnuca8rXO4I2P5Gy1lGrkxDDVK0P8I7XHWPap6rbQ6gCshSZFyJ7AVcy KQ2I6yesR5MsuINB+CDa4Z9ZKsofE3fVmg3TSdoxOfh9PVowML/pjUPGvplGpncBjDUb BY/sQTCHX3oAzofdGSz7ctHOyR8PTbENOFL84= 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=+YRDymGBWr25XFhfXR1fZ1bYzLQekf5JtaB4JC+47fc=; b=RXRHN9fxdyont+3Zm1zmyJYetvMLwFgI+f8BwxGy5/qMpSbcirJ3d73m1xAdDcAXsL emzF7gdFZYL9PVM8xjItyXNuBGIIvXxk3hPp7bxqMCUsPItMcUmEHIq+RxdS7yhJ1QYz 5uLqXSHbt5qc5HPfRO2sPeLp8Q/dfjxp1LURJD6WL7t9j4ZXiCDDDsHt95c7ADfwM0G3 vaYTTvMqh1T3Bg+wvHfQNC9GLTcFPzh/92z+PXHhDB73S4gcLpfc155wXJV504MAIR/5 9SSqWXiCmbvTdbW/bxLPDyVTljZgiF8+n9ZbqEcp7rRlwohfH+NhAGL/wGKhbfQG0IK3 T7dg== X-Gm-Message-State: AOAM531FGr7dl46/7EWvYwNzoSZMJr/uG00C3A2TOQIhGLdsbrznoMnG QAJPbIoLXWHOrVZU7678BR0UP9uTW9LIpoE94WwNoRJT0ItMbw== X-Google-Smtp-Source: ABdhPJzzV+A+dnJUcgtugYYBgh8vzAR9+whRRRGPODLLPZv+IVRTNgRB3qjukUYb0vlcf5R9dwXpMqlyRYJ1pNdu12g= X-Received: by 2002:a05:651c:4d1:b0:249:8a92:de38 with SMTP id e17-20020a05651c04d100b002498a92de38mr13607125lji.27.1649496594036; Sat, 09 Apr 2022 02:29:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 9 Apr 2022 10:29:42 +0100 Message-ID: To: Mel Dafert Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000008bc88c05dc355a26" Subject: Re: [PHP-DEV] NULL Coercion Consistency From: craig@craigfrancis.co.uk (Craig Francis) --0000000000008bc88c05dc355a26 Content-Type: text/plain; charset="UTF-8" On Fri, 8 Apr 2022 at 19:07, Craig Francis wrote: > On Fri, 8 Apr 2022 at 18:54, Mel Dafert wrote: > >> In particular, does this propose changing user-defined functions under >> strict_types=0 to accept null for scalar types? >> > > With user defined functions, I think it's up for debate (still a draft), > but I think those NULL's should be coerced to the specified type (as > documented), where I don't think PHP should be doing type checking under > strict_types=0. > I've updated the RFC to note that user-defined functions don't cause a backwards compatibility issue; but I have added an example to highlight the coercion inconstancy: ```php function user_function(string $s, int $i, float $f, bool $b) { var_dump($s, $i, $f, $b); } user_function('1', '1', '1', '1'); // string(1) "1" / int(1) / float(1) / bool(true) user_function(2, 2, 2, 2); // string(1) "2" / int(2) / float(2) / bool(true) user_function(3.3, 3.3, 3.3, 3.3); // string(3) "3.3" / int(3) / float(3.3) / bool(true) user_function(false, false, false, false); // string(0) "" / int(0) / float(0) / bool(false) user_function(NULL, NULL, NULL, NULL); // Uncaught TypeError x4? ``` --0000000000008bc88c05dc355a26--