Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117687 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84206 invoked from network); 7 May 2022 15:38:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 May 2022 15:38:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 648BD180054 for ; Sat, 7 May 2022 10:16:16 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15576 212.103.64.0/19 X-Spam-Virus: No X-Envelope-From: Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 7 May 2022 10:16:15 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 56EBE14A0 for ; Sat, 7 May 2022 19:16:14 +0200 (CEST) Authentication-Results: ext-mx-out001.mykolab.com (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:references:content-language:subject:subject :mime-version:date:date:message-id:received:received:received; s=dkim20160331; t=1651943773; x=1653758174; bh=cDLv1X5VykbhrRkx DjMiNNPISbz4qFMKmtA4HoLbOl8=; b=P8HuoyOW0u5XQy0jRLJ5H1VCL6vHO4bi qgH5I+lce/3G1vphpxKnjID4s+6zkZvmeEabsa7GEqulOY0/JOJb/dqHJwoJPlHk 7pTtYnvpKKFyHuU8HmSP1gGLKYaoxYw5r5ww0WynV8BzjQKhqaLAVxVodOZ9fte8 APj7xJ5pmejJxil8+ZForcMMQOrgcuuBsyEzJMu+NF8nOVfu0iy9ElO6xkef+3Ux ezR4qTr+7+4xHe8t1qgxgRCxS1UsSg+blATIf3taGWPMOtZ4RXPYTBhaOSAuZuSC ZjG3Z1s6S+v4i0V0AJq5JjDwGFPogC69R0HCTcJt0cYg39/Gc2i0Dq0TUz0NsaA0 JYL1W+w/ymNqIFh/m8BjEDIMCnN6mCAL5+uYXJLNDgRcYcYKXTsjr4cHBYN/TxCt 6H5Kc9jTQb5oCQpk5uDfild9PZwKRxZ2tho1sjMMdKJ+/E1ZMlrHuVwXYp+TqSor 48P7s2YsBulHX9tZSxn3NE8g1LqNGlhVqckKxs/kKVcqhqoDl+IKXfupBA4WsU8Z iE7ODgL2ggfNOOp+ME71qOUnFE6Vs6GZhS6Knz9+mt/L8nK8NaUkHYbdhKGGPZ/8 6SRy++yyLsLyNs3uEVsnE4IXD7JgLv5vgjoc6rNfzGQT57+kn2eu+ABMyd5LBfu0 YLK6xFh+QMw= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m-RK29J86xeE for ; Sat, 7 May 2022 19:16:13 +0200 (CEST) Received: from int-mx002.mykolab.com (unknown [10.9.13.2]) by mx.kolabnow.com (Postfix) with ESMTPS id 2BF5EDC8 for ; Sat, 7 May 2022 19:16:12 +0200 (CEST) Received: from ext-subm001.mykolab.com (unknown [10.9.6.1]) by int-mx002.mykolab.com (Postfix) with ESMTPS id C4CF92DB7 for ; Sat, 7 May 2022 19:16:12 +0200 (CEST) Message-ID: Date: Sat, 7 May 2022 19:16:10 +0200 MIME-Version: 1.0 Content-Language: en-US To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] NULL Coercion Consistency From: alec@alec.pl (Aleksander Machniak) On 07.05.2022 13:29, Mel Dafert wrote: > It is exactly user-defined functions that this RFC introduces breakage for. > The behaviour to throw on null in user-defined functions exists since PHP > 7.0, and is being relied on. Changing these now would introduce behaviour changes > that are harder to find than new type errors. > Using strict typing isn't an option either/would be just as much work as auditing > the changes this would introduce. > > It may be that user-defined functions should have accepted null to begin with in > your opinion, but that still makes it a breaking change now. Indeed. I suggest to add a note to "Backward Incompatible Changes" section of the RFC. This changes the contract, but does not throw new errors in existing code. Now my 2 cents, reading docs and RFCs (I'm not the internals developer): The https://wiki.php.net/rfc/scalar_type_hints_v5 says that NULL was excluded "in order to be consistent with our existing type declarations for classes, callables and arrays". So, to me it sounds like the main reason was that NULL can't be cast to array/object/callable, not that it was expected to be treated as a new type in the future, nor more strictness was intended. At the time excluding NULL made sense as it was a new feature anyway, and it didn't apply to internal functions, so it was fully sign-in feature. Although I must say that "it should be possible for existing userland libraries to add scalar type declarations without breaking compatibility" wasn't really true, because of NULL. You could call the proposed NULL-to-scalar coercion in weak-type checks a new feature that makes https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg obsolete/invalid, still, there are good reasons to do this. Imo, the BC break is much less problematic than the one we're trying to solve here. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com