Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117006 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88430 invoked from network); 7 Feb 2022 21:08:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2022 21:08:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B4EBC1804C4 for ; Mon, 7 Feb 2022 14:24:22 -0800 (PST) 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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3301 81.224.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from ts201-smtpout73.ddc.teliasonera.net (ts201-smtpout73.ddc.teliasonera.net [81.236.60.179]) (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 ; Mon, 7 Feb 2022 14:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telia.com; s=tssemail; t=1644272662; bh=WaMFXZr/fPJJ8X0v8Scx23udU0lZ/Wxtg0KCfZCaIro=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To; b=PvcVqA78TQuU1KtlWAY85LuiVoSUi4nlfb4Mh/H/mY7eGacZWXLXHA/3T/kfcZJmvLwkAKs5kip01HKGAnvmTFc+n1gI/t3NUTSbsC5UfGjD5ZUpFrhMoJLFAjpM3ar8SfXy897hxxcrb2TGViOBuHkIw+aModaqkwdrSNvOB1CwOMf7iZaqIm4qflw4lVB3aAGCFe/EP23Q2rnDkV8BQQJcSW3a1j3YbZ7MerQSgmAdIKBE4jdtOsjRlOUeEjqRcIzmvq0QnoFnMAsa3qmPLeJTlYrXsnSwHL5USYi68b4qowsX3nf8PS+EDmvycOFG7lUJhd5HkOFjG2JPHp05rg== X-RG-Rigid: 61A8980703FDAB22 X-Originating-IP: [84.216.97.240] X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvvddrheehgdduheejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvffgnffktefuhgdpggftfghnshhusghstghrihgsvgdpqfgfvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomhepuehjnphrnhgpnfgrrhhsshhonhcuoegsjhhorhhnrdigrdhlrghrshhsohhnsehtvghlihgrrdgtohhmqeenucggtffrrghtthgvrhhnpefhudeigfefgeduhfefleeftedvgefgteevheehgfevjeeivdekuefgudfgheevvdenucffohhmrghinhepphhhphdrnhgvthdpghhithhhuhgsrdgtohhmpdhfuhhntghtihhonhhsqdgthhgrnhhgvgdrmhgupdgvgihtvghrnhgrlhhsrdhiohenucfkphepkeegrddvudeirdeljedrvdegtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegludelvddrudeikedruddriegnpdhinhgvthepkeegrddvudeirdeljedrvdegtddpmhgrihhlfhhrohhmpehukeelledtieegudejsehpnhgvrdhtvghlihgrrdgtohhmpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheptghrrghighestghrrghighhfrhgrnhgtihhsrdgtohdruhhkpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopehpohhllhhithgrsehphhhprdhn vght X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.1.6] (84.216.97.240) by ts201-smtpout73.ddc.teliasonera.net (5.8.716) (authenticated as u89906417) id 61A8980703FDAB22; Mon, 7 Feb 2022 23:24:17 +0100 Message-ID: <08953636-760b-2533-6c8f-a2cc57535d7e@telia.com> Date: Mon, 7 Feb 2022 23:24:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-GB To: Craig Francis , Sara Golemon References: Cc: PHP internals Reply-To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: internals@lists.php.net ("Björn Larsson via internals") Den 2022-01-02 kl. 00:17, skrev Craig Francis: > On Thu, 2 Dec 2021 at 15:19, Sara Golemon wrote: > >> On Thu, Dec 2, 2021 at 8:48 AM Craig Francis >> wrote: >> >>> Is there any value in me proposing an RFC to update *some* internal >>> functions so they can accept NULL? >>> >> >> I'm not hard against this idea. The interpretation of null in these >> contexts as being equivalent to empty string isn't unreasonable. I guess >> the only objection I could have would be an academic one and I can't really >> defend that. So yeah, sure... why not? >> > > > Thanks Sara, > > I've spent a few days coming up with a short(ish) list of parameters that > are likely to receive `NULL`. > > The focus is on making it easier for developers to upgrade to newer > versions of PHP. I'm thinking of the typical developer, probably using > WordPress, isn't using Psalm (at levels 1 to 3, with no baseline), and > isn't using `strict_types`; where they don't really have the time to add > strval() to everything that could be NULL. > > Draft RFC: > https://wiki.php.net/rfc/allow_null > > And the list, where I'm proposing we only relax this requirement for the > *bold* parameters: > https://github.com/craigfrancis/php-allow-null-rfc/blob/main/functions-change.md > > I'll give it a few weeks to see if there are any parameter suggestions > (welcome via email, pull request, carrier pigeon, etc), then I'll start > looking for the best way to implement this. > > Craig > > > PS; starting new thread, as I have gone a bit off topic, original one at: > https://externals.io/message/116519#116556 > Hi, Thanks for this RFC! I think it could interesting to see how libraries that needs to adapt to this are doing it IRL. One example I have seen how to fix this for e.g. substr is to replace: $result = substr($string, 0, $length) with: $result = substr($string ?? '', 0, $lenght) So the null coalescing operator comes in quite handy ;-) Now if this is a good way to solve it is another matter. But if you are a maintainer of a library that works fine and wants to support PHP 8.1 this will solve the upgrade in a smooth way. Would be interesting to see how common this approach is for solving PHP 8.1 upgrades for non-nullable arguments with internal functions? I mean, it shows the value with the RFC from a slightly another angle. Regards //Björn