Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125806 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 685231A00BD for ; Tue, 15 Oct 2024 20:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1729023652; bh=YRsq7TjW8dgH6F46d20bnwvxLc6CUkvRlf3I8uAS7BM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=N+aPPFhAevNm2DpNNlXBplJ4nd+bdzMJoPqq+X/TZcYMEKgYDTAgndXaRsrc3L93x wnIdw+QCYA6N0yN4CAkasU6MY3fy4UqzzrzDj0fQx6Atii+5/WxM0HR/0NiGQAZwlc bkmdNO2COT1KyS6TrjRgT1iTgIm8snKtaxytLl1u5DljSEtPhH8WnJT6G4F47nSZly d0+0uw8BdT/fEGR9RyeS/MtEj4jBSSQPKO5wmwf0BGWLq2nh/iSSvTV+/GEUIxUMYl 48FBFKR9CZk6l6hIsKHuRrYPd1xD28it13/QG34ne5Pm89G/uQ6gF/S5dV6PPv01Qp /VvbEdkEwu3ww== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E0A5318007C for ; Tue, 15 Oct 2024 20:20:51 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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 ; Tue, 15 Oct 2024 20:20:51 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 56CEA11400D0 for ; Tue, 15 Oct 2024 16:18:29 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Tue, 15 Oct 2024 16:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1729023509; x=1729109909; bh=5D/NrX5Wgt 2QxbXAM1L9S+ivfY7AXW8i0o701Hm6JJI=; b=YMS0knV1jMyS5P1Do1QU3IUYgU 8iGQ/8ui286i4xE0BTRyKmh9hvAK/G6gJC838Z+/xYPNH3w43gQAEuE4jE1i2xPD Hhsk9imCQ2whHOG6FrFhgBW/ByBpO1JGNM8v6FofYzw1+/XzVnDMNAm8GDodT+DW S7pe/jBwOlWRAU2pd/C/CXg7+3zkhwiiHrKafGpl4XRabUkbAzW9NGWVv2K4qeZZ 3ssuXRff2cLvZByyqYUYdYXskJ+OLmNHRQf12HSatZJGz5Ausx9pZ/KCCtNf8KFY JuSwhuwVoZtr6dco0R/CuKUrKKOkzmbMyssPxSzxy82bOwbUeLqfbyIvujuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1729023509; x=1729109909; bh=5D/NrX5Wgt2QxbXAM1L9S+ivfY7A XW8i0o701Hm6JJI=; b=j/MQTI07WShdRNZH/r9rsrPYXBrmFrN5VoGXLu44bBTn nXjPxoYpwn6X6X0JJcgmLipgTNx15vrjWKIS1sCZd1BoOv5aNCsoc2OUlaUMUNOW ds1HEsXCGUJUr3o2ldHCtB0eNuDHbgJaGNn53d1ZcTlk9uLkwuktZQyj7Fmp0F6j dEycwd6WL/t2zRtCCycNzuC9u3T+05ZjT88mg1Y9d1yWYsTlb8TjUqhR33ZSIQJ7 jlwrv7BfBvV8syYR0gw3ZFR/Jc8O3TsOeYB+dDLgjlR1Qe23LOmVamqO1KLp6lJS 8rZmjgb1OXVjscijC3c3AlECIKqJmDpBZAYNM5j+PA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegjedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdf uceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhepuefhvd fgffelvdejleehteffiedtuddtheevgedvfeffgeelvdekudejtedvhfdunecuffhomhgr ihhnpeifihhkihhpvgguihgrrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghr tghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrg hlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id CBAB9780068; Tue, 15 Oct 2024 16:18:28 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 15 Oct 2024 22:18:08 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: <9399e880-f51d-4726-b4fa-9833e82ef2e0@app.fastmail.com> References: <2A7CF24F-3AE3-4125-965F-C65431C42DFB@gmail.com> <30a41608-a1ea-40a9-8d2a-c53c508cd89f@jnvsor.net> <3648840e-5c73-49c9-bc89-105ed761e5c2@scriptfusion.com> <9399e880-f51d-4726-b4fa-9833e82ef2e0@app.fastmail.com> Subject: Re: [PHP-DEV] Asymmetric visibility is a BC break Content-Type: multipart/alternative; boundary=1dca82df820e46e491b130010a09720b From: rob@bottled.codes ("Rob Landers") --1dca82df820e46e491b130010a09720b Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Oct 15, 2024, at 19:11, Larry Garfield wrote: > On Mon, Oct 14, 2024, at 10:27 PM, Pierre Joye wrote: > > Hello, > > > > On Mon, Oct 14, 2024, 8:07=E2=80=AFAM Bilge = wrote: > >> On 14/10/2024 01:02, Valentin Udaltsov wrote: > >> > The problem is that in practice most of the PHP libraries consider > >> > themselves to be compatible with newer PHP versions. > >> > > >> > For instance, Symfony PropertyInfo uses `"php": ">=3D8.2"` constr= aint in > >> > its `composer.json`. > >>=20 > >> That seems like a problem they have created for themselves. It seem= s an=20 > >> error to me to declare software forward-compatible with PHP version= s=20 > >> that do not yet exist and thus have clearly not been tested against= .=20 > >> Being as it is an error, we shouldn't consider it impinges on PHP's=20 > >> definition of a BC break. > > > > > > As much as I like this new feature and I am more than thankful for t= he=20 > > work behind it, if a test in codes using a x.y version of php works = but=20 > > fails in x.y+1, it is a BC break, no matter how we look at it. A php=20 > > dependency targeting x.* is very common. While it tends to be used l= ess=20 > > frequently as the amount of issues increase, that's not necessarly a=20 > > good thing. > > > > In some cases it is a necessary evil (extension deprecated adding=20 > > warnings, security fix requiring a bc break, f.e.). > > > > However, I am very doubtful here. And I do not know if it can be=20 > > avoided while keeping the new behaviors.=20 > > > > All in all, it would be great to at least agree that there is a BC=20 > > break issue, so it can be addressed according, whatever the final=20 > > decision is. > > > > best, > > Pierre >=20 >=20 > I think folks are operating with different definitions of "BC Break". >=20 > Consider: >=20 > // Foreign.php >=20 > class Foreign { > public function __construct(public string $name) {} > } >=20 > // My code: >=20 > $f =3D new Foreign('beep'); > $rProp =3D (new ReflectionObject($f))->getProperty('name'); > if ($rProp->isPublic()) { > $f->name =3D 'boop'; > } >=20 > Under PHP 8.0, this code works. > Upgrading to PHP 8.1, this code *still works* exactly the same. There= fore, there is no BC break. > Upgrading to PHP 8.4, this code *still works* exactly the same. There= fore, there is no BC break. >=20 > Now, someone edits Foreign.php in 8.1 to read: >=20 > class Foreign { > public function __construct(public readonly string $name) {} > } >=20 > Now, my code will fail, because isPublic() does not guarantee "is writ= eable" anymore. =20 >=20 > Is this a BC break in PHP? >=20 > I can see the argument either way, personally, but I tend toward no. = One PHP version to the next should always be safe to upgrade an *existin= g* code base. Just swap out the PHP binary and it should still work the= same. We want that. However, once you start modifying any part of the= code (including dependencies), all bets are off. >=20 > Suppose some library switched from using annotations to using attribut= es. Any other code that was looking for those annotations is now broken= , but it would be ridiculous to accuse attributes of having broken BC in= PHP. Or ancient PHP 4 code that just assumed all properties were publi= c (which they were in PHP 4), now confronted with PHP 5 code that has pr= ivate properties. Is that a PHP BC break? Not at all. >=20 > And again, the relevant change here happened in PHP 8.1. This is only= tangentially related to 8.4 at all, because isPublic() has not implicit= ly meant is-writeable anymore for three years. >=20 > --Larry Garfield >=20 Hey Larry, First, thank you for this feature. Second, attributes and annotations ar= e a moot point. Adding attributes didn't render annotations broken and i= s still (unfortunately) used today in many codebases running 8.3. So, in= other words, the deprecation of annotations is a framework/codebase/use= r-level issue and totally unrelated to attributes and PHP as a language.= While attributes helped with that deprecation, it wasn't caused by them= =E2=80=94people could have deprecated annotations without ever having at= tributes. According to Wikipedia (https://en.wikipedia.org/wiki/Backward_compatibi= lity) > In compilers , [and interprete= rs] backward compatibility may refer to the ability of a compiler [or in= terpreter] for a newer version of the language to accept source code of = programs or data that worked under the previous version. I think this is all we need: just a proper definition. Looking at the is= sue at play, we can conclude that it isn't a BC break =E2=80=94 code tha= t worked in 8.3 will continue to work in 8.4. Will things have to be upd= ated (or in my case, rewritten basically from scratch)? Sure! But there,= it becomes a framework/codebase/user-level issue on whether they will r= emain backwards compatible with older versions of PHP. =E2=80=94 Rob --1dca82df820e46e491b130010a09720b Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Tue, Oct 15,= 2024, at 19:11, Larry Garfield wrote:
On Mon, Oct 14, 2024, at 10:27 PM, Pierre Jo= ye wrote:
> Hello,
>
>= ; On Mon, Oct 14, 2024, 8:07=E2=80=AFAM Bilge <bilge@scriptfusion.com> wrote:
= >> On 14/10/2024 01:02, Valentin Udaltsov wrote:
>= ;> > The problem is that in practice most of the PHP libraries con= sider
>> > themselves to be compatible with newer= PHP versions.
>> >
>> > F= or instance, Symfony PropertyInfo uses `"php": ">=3D8.2"` constraint = in
>> > its `composer.json`.
>&g= t; 
>> That seems like a problem they have crea= ted for themselves. It seems an 
>> error to me= to declare software forward-compatible with PHP versions 
>> that do not yet exist and thus have clearly not been test= ed against. 
>> Being as it is an error, we sho= uldn't consider it impinges on PHP's 
>> defini= tion of a BC break.
>
>
= > As much as I like this new feature and I am more than thankful for = the 
> work behind it, if a test in codes using a = x.y version of php works but 
> fails in x.y+1, it= is a BC break, no matter how we look at it. A php 
&= gt; dependency targeting x.* is very common. While it tends to be used l= ess 
> frequently as the amount of issues increase= , that's not necessarly a 
> good thing.
=
>
> In some cases it is a necessary evil (exten= sion deprecated adding 
> warnings, security fix r= equiring a bc break, f.e.).
>
> Howeve= r, I am very doubtful here. And I do not know if it can be 
> avoided while keeping the new behaviors. 
>
> All in all, it would be great to at least agree= that there is a BC 
> break issue, so it can be a= ddressed according, whatever the final 
> decision= is.
>
> best,
> Pier= re


I think folks are operati= ng with different definitions of "BC Break".

Consider:

// Foreign.php
class Foreign {
  public function __cons= truct(public string $name) {}
}

// My code:

$f =3D new Foreign('beep');<= br>
$rProp =3D (new ReflectionObject($f))->getProperty('nam= e');
if ($rProp->isPublic()) {
  $f-= >name =3D 'boop';
}

Under = PHP 8.0, this code works.
Upgrading to PHP 8.1, this code = *still works* exactly the same.  Therefore, there is no BC break.
Upgrading to PHP 8.4, this code *still works* exactly the s= ame.  Therefore, there is no BC break.

Now, someone edits Foreign.php in 8.1 to read:

=
class Foreign {
  public function __construct(pu= blic readonly string $name) {}
}

<= div>Now, my code will fail, because isPublic() does not guarantee "is wr= iteable" anymore.  

Is this a BC = break in PHP?

I can see the argument either= way, personally, but I tend toward no.  One PHP version to the nex= t should always be safe to upgrade an *existing* code base.  Just s= wap out the PHP binary and it should still work the same.  We want = that.  However, once you start modifying any part of the code (incl= uding dependencies), all bets are off.

Supp= ose some library switched from using annotations to using attributes.&nb= sp; Any other code that was looking for those annotations is now broken,= but it would be ridiculous to accuse attributes of having broken BC in = PHP.  Or ancient PHP 4 code that just assumed all properties were p= ublic (which they were in PHP 4), now confronted with PHP 5 code that ha= s private properties.  Is that a PHP BC break?  Not at all.

And again, the relevant change here happened = in PHP 8.1.  This is only tangentially related to 8.4 at all, becau= se isPublic() has not implicitly meant is-writeable anymore for three ye= ars.

--Larry Garfield


Hey Larry,

<= div>First, thank you for this feature. Second, attributes and annotation= s are a moot point. Adding attributes didn't render annotations broken a= nd is still (unfortunately) used today in many codebases running 8.3. So= , in other words, the deprecation of annotations is a framework/codebase= /user-level issue and totally unrelated to attributes and PHP as a langu= age. While attributes helped with that deprecation, it wasn't caused by = them=E2=80=94people could have deprecated annotations without ever havin= g attributes.


In compilers=E2=80=94 Rob
--1dca82df820e46e491b130010a09720b--