Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123064 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 2C53D1A009C for ; Tue, 9 Apr 2024 17:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712684572; bh=oGBzs3zDYbBbjo/dsjVZs7zWW6PbXOlP9p8BWvZKzXY=; h=In-Reply-To:References:Date:From:To:Subject:From; b=cOCJIABVNTMzUUlxERhGqV4DvOXz+Vb6rA3y9qvZGP28s16NMiCyToO+DUrSm1vKw F3MateI3xU6rxHKjX6Kg6k7Z1T7hSb/OJqh+h5hY5XZOuQtu7ORlMPFq5UDpfP9le5 zui2KANPtWjm7iQIWCcoSegz+YygEv9JTRmwKQDaxM7nYlB8dWRfC7q7ExPeuoYM7V tEjrpyyV6O/5Wssmc8TNO9jYncXdMihf6JcGWWSZNB6Q+vC6yn3qMZrDSID65sphZv Xgxu8yh0xelVwrLg8fJ2KXF7Ztd52i3s6fWEz/GpXsn30llNO3uGOSt0h8eEILBE/U QRaLCMx6aks6g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB5EB18005F for ; Tue, 9 Apr 2024 17:42: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.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_NONE,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 wfout5-smtp.messagingengine.com (wfout5-smtp.messagingengine.com [64.147.123.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, 9 Apr 2024 17:42:51 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id DB02A1C0010D for ; Tue, 9 Apr 2024 13:42:17 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 09 Apr 2024 13:42:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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=fm2; t=1712684537; x= 1712770937; bh=LhcbhrwT40ERrzczB511mx5esIjpZ4GMrZ/ADXUIXtI=; b=X kjnC8Xyx475e2Ny5C6Yv7/Kp8/Ps+NbqzKNI8Gm7dIrGrKiuCPOeDc+1On4/uNPE I88DB4bcEmifpCEzdbxQhT//TFLyju5KeqvX+zNxz7F5ScmPWANtwM6Ue/1QssoU 1bZvAXgC7cEVAYMBOOfSIu49+Fg0ZITo948pyvAHrHJX5oe2mrvOD+AaRAqkHuFb I+V98eg/k1tYsv1P323m0YFrnaXhTA9mVwWVHq0psVvOOREb7d0Foa8Z7IXy4dmR 0tPAzVg0YUmoJYFx3T46vR/AQ51WKnGUjSR8EW9XtkD7iYA1NXN85DSWMHSlGx+J xewQPhRdTA0SXHFv4c+0A== 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=1712684537; x=1712770937; bh=LhcbhrwT40ERrzczB511mx5esIjp Z4GMrZ/ADXUIXtI=; b=qyMRknXedbyAPeoChVc56HGOzVphz/iVfK7b7Xco93Y7 r9drdChn1d6W/XSAHhckSscKMkwC3Q66l9GNT4LKKR4XDiQ/q02jn2QfWyRCpKWs H+hPQAV5GE5p+6Z2T9IfPh4997U0xMA95dNHsS0ex6KwSHAdeQ2jgkBv4MvGq1bj tVKjoESqBi1oJfqYekFLyc++onEmejVYVInp5B8JNcclZYUbETG6u1vEWRGcvtlA x7vBZgeTaldfHUhpQUpLn1ST8pEWIzTboqWnQdn07HFtopX4kRZ2h3vxqKSaToWR aNHlhpRRh02Pv919alcVK5a6PEL/ub8hT9iTjpjMaQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehfedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0BB491700093; Tue, 9 Apr 2024 13:42:16 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-379-gabd37849b7-fm-20240408.001-gabd37849 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <9ff3864e-7fb8-4ad1-bbd7-f8c69567a34d@app.fastmail.com> In-Reply-To: References: Date: Tue, 09 Apr 2024 17:41:55 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC][Vote announcement] Property hooks Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Tue, Apr 9, 2024, at 4:07 PM, Levi Morrison wrote: > I was playing around with 3v4l.org. Is the implementation up-to-date there? > > I don't have any hard objections at the moment, but after playing with > it for a while, I do kind of wonder if it's a lot of complexity for > what is effectively a niche feature because: > > 1. It does not support asymmetric visibility for get/set. Having a > public getter and private setter seems really natural. Aviz is a separate RFC, for reasons we've covered before: They're actually two separate features that do not depend on each other, so we split them up to help reduce RFC size (something RFC authors are often encouraged to do). The Aviz RFC was put to a vote last year but didn't pass. If hooks pass, we do want to revisit aviz and bring it to another vote, as the argument may be stronger now with hooks in place. > 2. You can't access accessors for "siblings". If a use case for this is found, that should be addable in a future RFC with no notable BC break. (Assuming a syntax of self::$otherProp::get() or similar, it would only have the same slight edge case as the parent::$thisProp::get() has, as documented in the RFC. As we've decided that is too edge-casey to care about here, presumably the same would hold true for such an follow-up.) > 3. You can't do by-reference set (important for arrays). This is due to logical limitations in the context. By-ref set means set hooks don't get called. So we can either block by-ref manipulation when a set hook is defined, or we can make set hooks easily-bypassable suggestions at best. We have not found any way around that decision. (And as noted in the RFC, this problem is already present if just using methods. It's not a new issue.) Please note that *the scope of what is blocked has been reduced considerably from earlier versions of the RFC!* The only invalid combination is &get/set on a backed property, because of the issue above. Writing to an array returned from a hook is allowed in certain circumstances, namely, if it was returned by &get and there is no set. So we're only preventing the narrowest set of operations we reasonably can, without hamstringing the concept of a set hook in the first place, and we don't believe there is any logical approach that would allow more. If in the future someone can come up with an approach that would work, it would likely be addable in a BC way. > 4. You can't satisfy a parent's readonly property with a getter in a child. In the last week or two we've figured out a situation where we may be able to allow this; iff the child getter works by reading the parent's value, then it would *probably* still be able to satisfy readonly's guarantees. We haven't tried implementing it yet as the RFC is large enough as is, but it's possible that could be added in the future. The main issue is that there's no way to fully guarantee that a get hook on a readonly property is idemopotent, the way a bare readonly property is. (It's not a lack of desire to support it, just the logical issues in ensuring different features' invariants are maintained.) Note that it's still unclear what set from a child set hook should do, given that readonly properties are also silently private-set, even if the property itself is protected or public. Potentially we could mandate that a child set MUST use parent::$prop::set(), so the actual write is technically in the parent class. I've noted this before as a design flaw in readonly that really needs to be corrected, but that's not a job for this RFC. (We actually had a solution in the aviz RFC, but people pushed back on it so we had to remove it.) > Now, points 2 through 4 are fairly minor and niche by themselves, but > if we take all these restrictions as a whole... I'm a bit worried. Hopefully the above comments make you less worried. :-) --Larry Garfield