Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122692 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 C710D1AD8F6 for ; Tue, 19 Mar 2024 17:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710869229; bh=weBqt5PpIUH3qzAT19VKK4/S9H0tv5guTeRdB32Ai4M=; h=In-Reply-To:References:Date:From:To:Subject:From; b=WIwZL7A+iK8Id0TQJF5/BAUUseCD+aGxNFcqI+r4Buuq63pfCVr79X+BHonJk65Tj qzcRtGSTKPmX+5/+S/cenUTFHl/ydxIVn1EZmSR5nGJNDECbXoMERgSwkbabTsg8vz kLDCq6xuVt92uXkuXkd9MRcoxARpMhF4fcE7g9yCtRlJnYmQ0xuya+nCEr1Heprehg vf5IoO3hSOvuMhCMTe6OKlts6/Y2yG8693AgER/1Df8Ctk9RAfZ7i9Z+gdVHVfqVzA kBA5uMKOZCTRfOhE8hJRzLZcEXwL66PtfVh8CidfvJi1Eyhof0+tNejoVjJBmvYSQh RGoy6TSEJ1EYw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A54901806B2 for ; Tue, 19 Mar 2024 17:27:08 +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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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, 19 Mar 2024 17:27:08 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 27E5A5C003D for ; Tue, 19 Mar 2024 13:26:47 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 19 Mar 2024 13:26:47 -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=fm2; t=1710869207; x=1710955607; bh=WH9IbHZwb8rSsDerwVMUo XycjaUQa3bllx1MjWjSUOI=; b=orJkxd6mVR6bd636Bi2zb9VXmTiKmpbphKLBn yeTXC9rLcMvfKjMp398V/Aj7j51VVLmRH/sAt0JYqyPqdYnWrBiKsoKoN8DGTimN zXs4eUm2XHpeD4ZgJ7Pc+BVAQAvNHsRcI8uqKDRs9nXE9veYJh35mDGmhtktnpGx NCQUFpPmo9Ig9RKokGdaGgj0PafyAP7J+EVVkdvMuWDKQR3g+dRATBxeDOlHmy2r 51fwU8HiBNoJEbGkeeQbGNSVItNBRjRf5MQRWfYq8/hWPI7Eis9/BYt1pOOy7RJl /MESe6CzkIn51m/+9aHarJzPivDNATNqeHbjuEif9iqd3XbTg== 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=fm2; t=1710869207; x= 1710955607; bh=WH9IbHZwb8rSsDerwVMUoXycjaUQa3bllx1MjWjSUOI=; b=K pcnZUPfDaF7tUr/EuE0Hqf5nl1sw8MLdSSqaBePQUT+PA5lpQUOTmZDXAQJT8Goh nmqVRWBkRftvLmnwlgav4JD2NKSMAWDSWBDpfKQbik7xzD3DTBQx7MUxlBE3SoHL /4+LEelpWFzxYkIsoj/J+v3YUQVGhlbFJMEIr1B7RkDTWKhbp5TJWbnrPwGwjYtU n7OiyWXNEtybIog92Uy5QWzdrL3eDOyIdTRW0cbXL/1Ob7vXR3lGawpRhUHIf4us pctO2U4yt3SG3Rht9osMkf7qWeG3ftOwambbUQBas8uYu/UybgvHgmksJg5rh/9w 9WrMPn5khsV3ITDAPU9Tw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrledtgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeggeehgfetjeehgefggefhleeugefgtdejieevvdet hfevgeeuudefleehvdetieenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhi vghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id BDB3B1700093; Tue, 19 Mar 2024 13:26:46 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-300-gdee1775a43-fm-20240315.001-gdee1775a Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <452aae1b-8929-4f08-a388-45b374d2a365@app.fastmail.com> In-Reply-To: References: Date: Tue, 19 Mar 2024 17:26:25 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Tue, Mar 19, 2024, at 11:16 AM, Derick Rethans wrote: > On Fri, 8 Mar 2024, Larry Garfield wrote: > >> Hi folks. Based on earlier discussions, we've made a number of=20 >> changes to the RFC that should address some of the concerns people=20 >> raised. We also had some very fruitful discussions off-list with=20 >> several developers from the Foundation, which led to what we feel are=20 >> some solid improvements. >>=20 >> https://wiki.php.net/rfc/property-hooks > > Some comments and questions: > > Be aware, the detection logic works on $this->[propertyName] directly= at=20 > compile time, not on dynamic forms of it like $prop =3D 'beep';=20 > $this->$prop. That will not trigger a backing value.=20 > > How can that not cause issues? For most uses that should be fine. But it's more that trying to do anyt= hing else would be vastly more complicated and error prone for the imple= mentation. And most people hated the alternate $field variable from Kot= lin. > The set hook's return type is unspecified, and will silently be=20 > treated as void.=20 > > What happens if you *do* specify a return type? Will it Error? Yes, it's a parse error. > Implicit ''set'' parameter > > If the write-type of a property is the same as its defined type=20 > (this is the common case), then the argument may be omitted=20 > entirely.=20 > > =E2=80=A6 > > If the parameter is not specified, it defaults to $value. > > I am not a fan of this "magical" behaviour. Do we *need* this short cu= t,=20 > and the following "Short-set"? We believe we do. One of the goals of the RFC is to reduce and avoid ve= rbose boilerplate. The short-hands should be the common case, in practi= ce. The only reason one would have to specify a set parameter is if the= re was a good reason to change the variable name or widen the set type. = Both of those are a-typical situations. > With asymmetric visibility that was previously proposed, the=20 > example can be further simplified.=20 > > But it isn't here, so why is this example (and the next one) in the RF= C?=20 > :-) Many/most languages with accessors also have asymmetric visibility. Nik= ita's original RFC also combined them all into one. The two RFCs are no= t mutually dependent, but are mutually-supportive, by design. So this c= omes under the "why didn't we include feature X" heading, with an answer= "that's in a separate RFC." > Interaction with constructor property promotion > > =E2=80=A6 In particular, the shorthand version of hook bodies and the=20 > ability to call out to private methods if they get complicated=20 > partially obviate the concern about syntactic complexity.=20 > > Although that is true, it *does* add more complexity in tools that nee= ds=20 > to parse PHP, as there is now another piece of new syntax that needs t= o=20 > be added (and tested with). That's true, but it's also inherently true of hooks themselves. And any= other syntax improvement to the language. > ReflectionProperty has several new methods to work with hooks. > > getHooks(): array returns an array of \ReflectionMethod objects =20 > keyed by the hook they are for. > > What will the name for the &get hook be? And shouldn't there be an enu= m=20 > case for that as well? &get isn't its own hook. It's still a "get" hook, it just returns by re= ference. So it will be available with the "Get" enum value. If the ret= urn-by-ref status needs to be known for whatever reason, that is already= available on the ReflectionMethod object that is returned. --Larry Garfield