Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123069 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 7E9DC1A009C for ; Tue, 9 Apr 2024 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712691209; bh=2QfYKP9+2UnHKjCIRxIX/qlKNAzRHMYsJ1JUnuzcb2o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bsRULnJr28ogBNH0vhRuEC14P8bL8NjyvH2MT9ch3YN2goz0cPRPHJzYzL5Wt5nQ1 evbpm37BfD1nKJ2JPlhTBu6dCqYsQ0L1stQRr1mVxPVQU1Wyt1nlEfLzYqPHrxfgfs Ts1KwASSFKY/CLKY0CEOK71hjiZnxr2OLsLNWcfzTX+YiZ0JTbN8fFjt3qFg9uEXnG Ru15WdxaipnyBP5s+rAcPCXqvcF9c/DkK4vx1uJeDGU3mE+ZTh0wT4VcW+DIFVzp6N GxSiB5hklOy9Dna3OzwuGRq1KOU1ZARDBg+6H3VE7Gims2e2VpI1Tdi8Y7uwshUbGf Ipj5xsyecjX6Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 38173180B76 for ; Tue, 9 Apr 2024 19:33:27 +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_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 19:33:26 +0000 (UTC) Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-5aa2a74c238so2000876eaf.3 for ; Tue, 09 Apr 2024 12:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712691174; x=1713295974; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=psu3+l9iONO/CywGhIzy6p9xg9HDssma/jxzBln/wF0=; b=h95oCVgyn1g/VdjMqO01IuIY7kXEEOo2vmwv0OYUIsZaZwtkBnttF+pRlzcpCYfYQQ D3LIKKWJefd2GcsmbRo70FxaB6MB0lipXph/mo9dvRLHRF9WlnkN2oHdqKH6VyZMF+JS WsarSxeigxKq4CAOePfNjqYjPusO7tiFjjY+bi1JGv9ow7zbbMk54dDIvAW01m/sPZN6 UyIkWRNwQkUXbkerNaEZc3eW43+9naDgclPi0jUJb7AyqD/NZcgjSzbv0Qf2Yk2xSNeX +ycBCnxlUvs7if5tDo4mpiqA7OCB1ELVJftDsdSUxka5rZaBK4HgMbrcalhGtgarPkon PPzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691174; x=1713295974; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=psu3+l9iONO/CywGhIzy6p9xg9HDssma/jxzBln/wF0=; b=m7I4dYOTTr4Ra5CyTUn7PI0fcjE0ECw/Yw4ndrCP7Hr9m0eTvuschuq0yvnTgD6Hac rsiDMAI57i+VkIQeCNBYxl0Kz3GQC6kNw7NQGR0Xi1VerKM9Ol9uzJMoqlROgNXA8ttC xJ/ivsRUf+fXMDwALyE2KuyATS2peGi8bCvjl0trgOvbrR0AZG1IE2bwuW9AyvGpVrV1 MW8kTd1ELI4AFfpQM4tZDngGOvSBgxIOQqxAoJKC22vHk3mNbyrKNerAZ78XgjvTZF3j n75aCYLAZQZ7rlsKvxjxVPA0DoNtN3Iu5tBU0/0PH9FNr2rhoblFTXfDJ599odFQmkf/ rZWA== X-Gm-Message-State: AOJu0YwTnVy897P+2hBnZi0GHAnm7i+7qVTFUZCL/sPTIStY8BNsCNFL OBllvh8DdNALUGFMOKNUDyjgoiq5S8c6If6QA7bJ+AcAA7AkJmvPcuTeZtk4U12u9IR6LlQlyFK +8g8OvcHh5xZU+h4ngW2apObjt7ySsZz7La0= X-Google-Smtp-Source: AGHT+IFChTQcJEawWe24siK6wxJ/9boZs8ukSp4Ye9u8RrQjEZ/TAr9Fw20VVi4B420QcAS1lc+nPGm1C2iZ5k25eRQ= X-Received: by 2002:a05:6808:6385:b0:3c6:9bf:4c36 with SMTP id ec5-20020a056808638500b003c609bf4c36mr88859oib.4.1712691173616; Tue, 09 Apr 2024 12:32:53 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <9ff3864e-7fb8-4ad1-bbd7-f8c69567a34d@app.fastmail.com> In-Reply-To: <9ff3864e-7fb8-4ad1-bbd7-f8c69567a34d@app.fastmail.com> Date: Tue, 9 Apr 2024 21:32:42 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC][Vote announcement] Property hooks To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Tue, Apr 9, 2024 at 8:56=E2=80=AFPM Larry Garfield wrote: > > 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 th= ere? > > > > 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 actuall= y 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 d= o). The Aviz RFC was put to a vote last year but didn't pass. If hooks pa= ss, we do want to revisit aviz and bring it to another vote, as the argumen= t 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 w= ith 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::$thisP= rop::get() has, as documented in the RFC. As we've decided that is too edg= e-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 i= n 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 considera= bly from earlier versions of the RFC!* The only invalid combination is &ge= t/set on a backed property, because of the issue above. Writing to an arra= y returned from a hook is allowed in certain circumstances, namely, if it w= as returned by &get and there is no set. > > So we're only preventing the narrowest set of operations we reasonably ca= n, without hamstringing the concept of a set hook in the first place, and w= e 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 c= hild. > > In the last week or two we've figured out a situation where we may be abl= e 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. W= e haven't tried implementing it yet as the RFC is large enough as is, but i= t's possible that could be added in the future. The main issue is that the= re's no way to fully guarantee that a get hook on a readonly property is id= emopotent, 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' inv= ariants are maintained.) > > Note that it's still unclear what set from a child set hook should do, gi= ven that readonly properties are also silently private-set, even if the pro= perty itself is protected or public. Potentially we could mandate that a c= hild 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 t= hat really needs to be corrected, but that's not a job for this RFC. (We a= ctually 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 Off-topic random thought: > The Aviz RFC was put to a vote last year but didn't pass. It would be really nice if votes weren't just a yes/no vote, but yes/needs-more-work/no vote, where needs-more-work and no are effectively the same in terms of passing the RFC, but needs-more-work just means there is more to do (either addressing ugly syntax or the idea is sound, but as it says, it needs more work), and can thus be simply revoted on after concerns are addressed -- instead of creating a whole new RFC that needs to pass the "not too similar to other RFCs rule." I got the impression from the Aviz discussions that most people were against Aviz due to the syntax, not the feature itself. It would be absolutely tragic if this failed to pass simply because people expected Aviz here. Robert Landers Software Engineer Utrecht NL