Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119797 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75273 invoked from network); 30 Mar 2023 16:47:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Mar 2023 16:47:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 748EE180538 for ; Thu, 30 Mar 2023 09:47:42 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 30 Mar 2023 09:47:41 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4FBA25C0108 for ; Thu, 30 Mar 2023 12:47:39 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Thu, 30 Mar 2023 12:47:39 -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:sender:subject :subject:to:to; s=fm2; t=1680194859; x=1680281259; bh=oGf0NWRvLP fgzWE18aXqPZuLW48dDxTn05Zfdc4wJ24=; b=uPZgCjNsU3S4q6bnxzdqGAaSKa hcwLeW2tKCfycscDPbz79sBgD80y0BpRsDCRhAMYbZXWCI+OdWIzIuVuR6G6eLwR NSLc94V0CidvNxtS5QtCkqr3GzFZ/t3qzh/Oal2M6PENiZjAPLfeePrUyqeYrOTx L/WzJBIJyZbMSkDIkSyu8Mq7cRMFq1rnLLPuQ3tU5TbEDoYogipGcqT1owXuJHai 47Yk6FzvtgoGpDnlr4fMOGaUzDYh43sSV/vDXu+PoWhcYstTU5IB5/XkpeHgqruQ MVZUl0iecqd0Xr9KqAVmwvbKKMfIHunSJnxixQe+D1+GG8+Ny+zzVY43qN4g== 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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1680194859; x= 1680281259; bh=oGf0NWRvLPfgzWE18aXqPZuLW48dDxTn05Zfdc4wJ24=; b=v uulzNvvEodO4lSYAeIJZ1/RAK06foGuXHNf86iLw3vtPjRrZ+M7vY43TMQXfspuc LcO9nLEWj59TFD9R37lWkGhaYdctnuwwYiMHTfKApiW4LRkrv/lQ6dwMoas5Cbds MFKz67gkz1oonCIrWnRTOutj7FdGVGdqafotMYfBIbEl/V/B27qAqc3/QwmKuxd7 zzKDSZ9SHFvBIP9iq6pUXr5ibYbuQv7769qubMCtIkxW4Vsvo0n6agBQ6AQHB5Eq ICwrnhM8BQm7seGX4Fz5YGCSnv8B9X68ojG4xw/5pyKr/A0INWhwmHDtNGTIaeeE k+Giph9ihiyCmyCt9WAMw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehledgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeeghefgteejheeggfeghfelueeggfdtjeeivedv tefhveeguedufeelhedvteeinecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 178EA1700096; Thu, 30 Mar 2023 12:47:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-238-g746678b8b6-fm-20230329.001-g746678b8 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <080d1241-0956-41bf-aaf3-d9582cfce3ef@app.fastmail.com> Date: Thu, 30 Mar 2023 16:47:18 +0000 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Properties in interfaces From: larry@garfieldtech.com ("Larry Garfield") On Thu, Mar 30, 2023, at 2:21 PM, Alexandru P=C4=83tr=C4=83nescu wrote: > On Thu, Mar 30, 2023 at 3:50=E2=80=AFPM Larry Garfield > wrote: > >> >> This is a part of the "Property Hooks" RFC that Ilija and are working= on. >> It's not *quite* done yet, but it's mostly there. The draft is avail= able >> here: https://wiki.php.net/rfc/property-hooks >> >> > Do you think we could have a smaller RFC that only deals with properti= es in > interfaces that are just like what's allowed in classes right now, pub= lic > and public readonly? > The need seems to be: a readonly property in classes and a interface t= hat > signals a get-only access so maybe readonly flag on interface attribut= e is > clear. Not really. For the hook-friendly version, we need to be able to separa= te get and set requirements. Hence: interface I { public string $foo { get; } } But separate get/set requirements is not a feature that exists today, si= nce asymmetric visibility didn't pass. So that would mean either includ= ing syntax that does nothing but hopefully will in the future if somethi= ng else passes, OR leaving that part out: interface I { public string $foo; } which then wouldn't work (or at least not as well) if/when hooks or asym= metric visibility get added later. =20 As for readonly, the more I've worked with it the more I think readonly = is fundamentally broken. Trying to use that as a "get only" syntax now = would be confusing, or restrict the property in ways the interface shoul= dn't. (Because it would require the property to be readonly, which has = all kinds of other implications the class may not want.) And then it wo= uld be confusing if we DO add hooks or asymmetric visibility in the futu= re, which would need to use the `{ get; set; }` syntax, but now you also= have readonly in there, so how does that interact? The best answer that leaves the least confusing cruft lying around the l= anguage causing problems is to do hooks and interface properties togethe= r, so they can be complementary. We considered doing interface properti= es separately as a third RFC, but in practice they're most useful if the= re are hooks available so decided to just combine them. This is one of those cases where our lack of roadmap and planning capabi= lity really kneecaps PHP's ability to evolve cleanly. And we really don= 't want to make the same mistake as readonly, where doing the "junior ve= rsion" first actually makes doing the full version harder, not easier. --Larry Garfield