Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126866 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 84A591A00BC for ; Thu, 20 Mar 2025 16:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742486269; bh=/GeimBycHAehkyFEo7PsV3QDXCYeh480k95jvCbQyj8=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=bbohoNpX2BYYDszuRBVmOEt/4/nahLS33r//6sKP4t8J+5PKn2aCTAZKvIb2ttAtA Twz5Q0mDWCg1HG3q/8FnH7nRnmOl12ADINNL7b+Kl4JNkhe1zgkmTytG1Trpkm8Azp YZT9bzVJgSaKNPbqYavQMsvXapTJse2Yi+B8hMkK0fbsQZSnl1StJoDFGgM3/3dI0+ PF6dYryDe1vym4dF5DMrCFtDiY/7yryvFCLqrhVcPo+Ftomsez++YhGiPzRM+C78Gy h9aLCli3UuG40UyGXRWEvU44d4dYMT1G2hf08lgH4TbNg66opZnsK5DDEZRL+q0BTd /yui+7Ha7fyDw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BF4D7180389 for ; Thu, 20 Mar 2025 15:57:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-4317.protonmail.ch (mail-4317.protonmail.ch [185.70.43.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 Mar 2025 15:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail3; t=1742486415; x=1742745615; bh=/GeimBycHAehkyFEo7PsV3QDXCYeh480k95jvCbQyj8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=ZIVsjot+WiweC5QyZDG+u1KSWvo3KFWP2sIwIF5Qxfx2MJifcz1YLfMhPF0Jgu/vV zBI/IFxqN9dznA1X5povREBjyqcgJpHuSLq4AT65g2iF0mdsn4hfQCkvE8h/qmq4gL kXQVir+cP1561tbkMUjH0qZ82WpVrM5EnKWtJBFKvbD93EHHgHEGGdqbjQ+DdIFgS7 blb9drF//rursGy0bz/+vQ1e+S6xPVDIs1zsnt4haZzPVf3DfhevIx97ZP/4mXrZuv 9wMpcAxJFZcJ6hdQ5FTIxMcB1e0pmVnQdBY5j23IR+V0luRdm8+M8wznjTd+m1fX5d wwed7zsJ9fi2w== Date: Thu, 20 Mar 2025 16:00:06 +0000 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Consensus on argument validation for built-in functions Message-ID: In-Reply-To: <95d08053-7500-4cc3-b84b-cb7cc837c065@rwec.co.uk> References: <041d1a8c-dd43-4592-b997-ad4d2f91aeac@app.fastmail.com> <95d08053-7500-4cc3-b84b-cb7cc837c065@rwec.co.uk> Feedback-ID: 96993444:user:proton X-Pm-Message-ID: 20ad28fd46086d1ee24ddff6b68a7802f4a25806 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Tuesday, 11 March 2025 at 21:17, Rowan Tommins [IMSoP] wrote: > On 11/03/2025 11:54, Gina P. Banyard wrote: >=20 > > It also means that we need to do multiple passes, on the same code path= , resulting in somewhat of a code churn and possibly not using a common abs= traction. > > Considering that we didn't even have the time to properly remove some d= eprecations from PHP 7 with the PHP 8.0.0 release, nor convert all relevant= E_WARNINGs to Value/Type errors, I expect that we would be missing some of= them again when PHP 9 comes around. > > I wonder if in some cases, we could automate this within the source code > - e.g. with a macro like WARNING_OR_ERROR(message, > first_version_for_error) which checks a compile-time constant for the > current version. I realise that still requires code cleanup later, but > it means we can't miss our chance when the appropriate version does come > around. I don't think this is an improvement for the maintenance side. > > and this is ignoring the fact that PHP does not follow semver >=20 > This is true, but only in the sense that something under the MIT license > isn't under the BSD license. Officially, PHP's release policy is > extremely similar to SemVer. > > [...] >=20 > Now, what exactly constitutes "backward compatibility" and "userland API > compatibility" can be debated, but there is currently no agreed policy > allowing "small compatibility breaks". >=20 > The fact that everyone acts as though there is such a policy, probably > means a rewrite of that document is overdue. A policy that nobody > follows is no use to either contributors or users. Yes, rewriting this policy would be a good idea. There have been BC breaks in every minor release going all the way back to = PHP 4. > Maybe we could work on some criteria that could be applied (and > publicised to users) about what is and isn't allowed in minor versions. > > [...] > > We'd probably still want some kind of deprecation policy - some changes > should be deprecated for X releases before removal/change. Which brings > us back to some kind of criteria for which changes need that, so doesn't > really solve the problem. Indeed, none of this really solves the problem. I think it is *fair* that the Core language has more stringent requirements= on BC than anything else. The standard library being second in line for this sort of considerations. But every other bundled extension should be allowed to have way more leeway= in what said extension maintainer wants to do. Making a distinction between Type and Value errors is meaningless to me, if PHP had a stronger type system, e.g. dependent types, then, a lot of things we currently consider ValueErrors would be TypeErrors= . If we were also designing some of these functions from scratch today, a lot= of parameters wouldn't integers, but enums. The only exception to this are bitmask parameters, as we don't have Enum Se= ts (or Intersection Types as values) which would replace those. And again, ValueErrors are only ever added when it *easy* to check if the c= ondition is satisfied, and it very clearly points to a programming error. I still find it baffling that telling someone that the code they wrote, eve= n if it is decades old, is incorrect is somehow bad. Because the alternative is letting users have bugs in their software that t= hey can ignore. Best regards, Gina P. Banyard