Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123516 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 8974E1A009C for ; Wed, 5 Jun 2024 14:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717597817; bh=lmDE0JXVB7ROMLCTsLah4r0SRsgeMfDw9HrFnqt+k4c=; h=In-Reply-To:References:Date:From:To:Subject:From; b=N6q35QXMVDCHdCJJvwJBn3YiPTewqVnvdZSPoOGwN/TtO4u3rB0v7wA56n481CXVP 2BHoovTQbAZzYK3CIViaPQ2Fj6TOWRwq0bHQR7HWMnCDsDTWRBBxgBD1L2P3lWSRmX H8OlwQX/T1nPES3FZrjP9DuA4hbvmqhN80/CH5SEjUkm76H3A6MVVxj7yomEqeb/w9 NsWY2D5RzJluJhLPvrZEw5wJ6GfViTlnsGmpijgCIaC12tqhU733SKDoA6Lsi0Ws89 cHQi7gT7KvTiSptLuXu2B1VD+j6fk8ETwUJA4KETpNIRmKgcW2tR2KmMGXcG5y1w/Y +SdKE4yCbbUXA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ACF6D180057 for ; Wed, 5 Jun 2024 14:30:16 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (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 ; Wed, 5 Jun 2024 14:30:16 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 240D713800F2 for ; Wed, 5 Jun 2024 10:29:11 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Wed, 05 Jun 2024 10:29:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm1; t=1717597751; x=1717684151; bh=zu6ks5uq3do7v12GAFNC2 Ga7oJJ0yCpki1jxgcYpWtg=; b=gICW14Q/g9nRQRCBlmt66kq6cJXh5d9Dlrs1i 4e6cEchxKtiKdlpScSDIldH5wSIpQuTVkoKaG/HH4OFZ1fcH0XM+hvEFVeTVR+Dc KtTDy+vftJ1Gjocr2VABEJdvfMqLbjoO0dLW6OLBz3l6JNc0mSGYaSIJf6usArwN DlqKNAyEpddyLy0M/yhAqXgfB10z/96jHt2De4D+MAhR+rTTOvV2f1dNQN2XbHtp v6+qyA+NCyq9fbYCe3NDr6B0Wkxjs3Up4bhgxD8zFZfvm5L780TeV1D5osFlS/br fm1igXJRHbOG6XU8ZQHQM4idhN69i1XlEQerXw+wZHZQF5QgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=fm1; t=1717597751; x= 1717684151; bh=zu6ks5uq3do7v12GAFNC2Ga7oJJ0yCpki1jxgcYpWtg=; b=B /GTcRc+RrkO5j2R4/nOeKu4LUTOy63Zbjwgaz0w9htYyPk9FfowxRW8GdnGV2SG6 +3TQJacOygA/JFZB9yco8m7p96MQe8uxjskIBOfuOuo8TQP7dPCkmYjy4BlPweJK eh6+EoundTjISrkX8UAKxuYpwWIA9RomClLbvHvMs0SJ17AHggqmWV/ioAauNasR 9LA4/51Jf76v2xfnd1bZRGkVFLe/4dr/UGklAA3b6uQBV58bKPgd8EfddeJPiGhC RTsOkpHMWX3ZDbHi/VqCC/WnBciTiHs2tCe8+xDrG2kuGkDshad6Q2gsEz7nfp/I 6ZkTT/rQlPHeKEaV3KNCg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeliedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A06A51700093; Wed, 5 Jun 2024 10:29:10 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-497-g97f96844c-fm-20240526.001-g97f96844 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <6d644f0f-cbeb-484c-b267-bf1d97e6d27a@app.fastmail.com> In-Reply-To: <89b695d7-661f-4c1b-ac4c-4480ad158e83@app.fastmail.com> References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> <734bb8e8-2fdf-4e50-9039-e53c99ee4930@app.fastmail.com> <89b695d7-661f-4c1b-ac4c-4480ad158e83@app.fastmail.com> Date: Wed, 05 Jun 2024 14:28:00 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, May 31, 2024, at 8:59 PM, Larry Garfield wrote: > On Fri, May 31, 2024, at 5:45 PM, Claude Pache wrote: >>> Le 31 mai 2024 =C3=A0 18:08, Larry Garfield = a =C3=A9crit : >>>=20 >>> However, this also brings up another interesting issue: readonly pro= perties (in 8.3) DO allow redeclaration, essentially adjusting the prope= rty scope (the class that declares it) to make the visibility check pass= . That is, the definition of the class it is private to changes, which i= s different from how inheritance works elsewhere. When the parent write= s to the same property, a special check is needed to verify the two prop= erties are related. All that special casing effectively means that read= only in 8.4 wouldn't really be "write once + private(set)", but "write o= nce + private(set) - final", which is... just kinda screwy. That means = our options are: >>>=20 >>> * A BC break on readonly (not allowing it to be overridden) >>> * Make readonly an exception to the implicit final. >>> * Just don't allow readonly with aviz after all. >> >> Another possible option is: >> >> * Make readonly be `protected(set)` by default. >> >> That would weaken the originally intended semantics of readonly, but = in=20 >> a compatible and acceptable way? >> >> =E2=80=94Claude > > Only sort of compatible. It would allow readonly props to be=20 > redefined, and wouldn't break any existing code, I think... but it=20 > would mean any time you use readonly, suddenly a child class can come=20 > along and mess with it out from under you. > > In practice that's likely not a common concern, but it is a behavior=20 > change. I think it's possible (I need to confirm with Ilija), if we=20 > want that slight BC break, but I don't know if we do. > > --Larry Garfield Ilija and I have been discussing this issue over the last few days. We = agree that `private(set)` should imply `final`, as that eliminates a bun= ch of issues both implementation-wise and expectation-wise. However, th= at causes an issue for `readonly`. =20 The root issue is that if we say "`readonly int $x` is really just `priv= ate(set) readonly int $x`", that runs into the issue of "whelp, you've j= ust made readonly always final, which is a BC break." So that's no good. We see a couple of ways to resolve this, presented below in our order of= preference. 1. Disallow readonly with aviz =3D> No BC break, and we don't need to de= fine readonly in terms of private(set). The only really useful combinat= ion anyway would be `readonly protected(set)`, in which case the protect= ed(set) is doing 90% of the work already. There's few cases where the r= eadonly is truly necessary at that point. Any other oddball edge cases = could be handled by a custom hook. 2. Make `readonly` implicitly `protected(set)` unless you explicitly spe= cify `private(set)` =3D> Would have the most consistent result, and this= is probably the cleanest in the engine, as `readonly private(set)` woul= d mean exactly what it says on the tin, with no inconsistency of "well i= t's kinda sorta `private(set)`" as `readonly` has now. However, this wo= uld be an expectation change, as suddenly all readonly properties could = be written to from a child class. That may be good in some cases but it= 's possible some objects could have unexpected behavior if they didn't e= xpect to be extended. (No existing code will break, but you could now d= o things to it in a child class that the author didn't anticipate.) 3. You can't mix `readonly` with `private(set)`, but can use other visib= ilities =3D> No BC break, and we don't need to define readonly in terms = of `private(set)`. However, it means the implicit `private(set)` of `re= adonly` and an explicit private(set) behave differently (one is final, o= ne is not). It also unclear if a `readonly` property can be overridden = with `readonly protected(set)` only, or also `readonly private(set)`. I= f the latter, does it become implicitly `final` at that point? 4. `readonly` behaves differently for an explicit (final) and implicit (= not-final) `private(set)` =3D> No BC break, but it's kinda weird and non= -obvious to explain. It also has the same non-obvious inheritance quest= ions as option 3. We consider only the first two to be really viable. For simplicity, we'= d favor doing option 1, and if desired option 2 could be presented in th= e future as its own RFC as that is technically a behavior change, not ju= st addition, so deserves careful consideration. However, if there is a = clear consensus to go with option 2 now, we're open to that. --Larry Garfield