Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122525 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 0F02A1ADA75 for ; Tue, 27 Feb 2024 20:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1709067124; bh=ABbeJphCXUZlQTw6wo4DvMYP//Yfq42Rbb8Q91YPIpQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jx0yZ4fzdIMMTEAgKrR0K7VTsk9h28MPS4DLCYbUvy2sT7u/BX3EL/qY3BSXAr0oQ Up+Rb+k6/DwAF8nADeS3Ztt+AoPDy/BGO5DCFs/47qTuv7Dju8OktppFaRqp39xWFh dWCj3KKqzodh0zJNGtOoJnXY6Gvypen6gjt9BaN5iuN+k4PDLHM/C+2AtdOOn66nUQ txe+MWYQ8XJ/3bZ7M28XiQor2iV1RHU/zX1nXkQgWgEnI/xSitqaTHNdg7JPPymkqv ifQjCcS2nHvOf7AcZBydk2GRjSKBzKW2bmr0/mxwi39U+M7oJ7/YIUTYBhag1HHN8Y SpTrdkbr8N8yQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 34944181D3C for ; Tue, 27 Feb 2024 20:52:01 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (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, 27 Feb 2024 20:51:57 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dcdb210cb6aso5388973276.2 for ; Tue, 27 Feb 2024 12:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20230601.gappssmtp.com; s=20230601; t=1709067108; x=1709671908; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ppWN03qj7Dcu/1J1XKTYyeid1UkSiYAYiNDGSlj6Ig0=; b=V4IUOAAglPO5MwOOJeJ3mKexzPS8U9AzmAqm1wf6WVzfhyweo47b/Eet7AQmZ5gcG4 YJ1ECat2tPXyDuT8L2UrqPmTKiS1KbL44BiBiDvb6jil0P1v2l7Ejk6ykLT+gPOJsmtm 2SPGvDYkNJIkz7Bjm+s0+YbiPOsrBFtfssdahOfUofiI4d1CAcSss5rx047KjNRGQJbP vpefP9oZDNLb5q0bRDqGNMDp5JpRTBgpbv0bzEXXUQggEUVDo93Q+ZWvD7OIsYk7KmOz PZ1XmoabCNxfjtFhcYyfdOefl1YaTzqITzo0Pk/HZkkkRDz9xscp9wv0wpFYAr9zbni6 yGFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709067108; x=1709671908; h=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=ppWN03qj7Dcu/1J1XKTYyeid1UkSiYAYiNDGSlj6Ig0=; b=XgPXlI02ZExkoybOfTaJS4j3dNvqDG8Oh9vJnd17JkA2WQMXZriXKzp0JJRjbcV/lk +0ocNirJ/yqA/b1S0r8gUuX7ZyOX1jntXSRTS8hn00fv91xdlJi3g1cLGUCl0steUaYp zB0vRCb+sPuqIrFRZXsNrKTjQhzBkkpIoY/Met08Rv8bJJKmWxFi5sdh5tuTbir+NIB/ L4+w2RXht1TksRfwEY5imrB4lCTM9B1U2ueCeNA8Q59oCQPYRWQh1oTeapRF/JPXBMgc Uri+Aijt/BLqy8MYRmuYHPXGsIeuZbyalxM6ZKNOJiSDJ2TqTKAAetkSA8wSXThf4vK+ Tmtw== X-Gm-Message-State: AOJu0Yz7LHYbNjhsNLp6CgTN0Wp34llaBt0qtCfyD8kkYidqrC6vZ0o9 l4Gj/tX/Vy8ekS2nxbcUIQpEGyzDLPmjKNi20wUbY+YiVgtbrEOYUvq0ZuDVaeGZpnBEdFfte7y SmoLej9NtmBF/4s19c9iYF6jn9fwVwtbfg5wiWb4uQvC6ScCAF7M= X-Google-Smtp-Source: AGHT+IHMceev7iCdaPQ3TfPEcmgkCScXJLY9KpghBcWvwFqQw5gnMgq80x/bV8vFyDmni01sOEv4yEWhcR4IIRxJ9Xk= X-Received: by 2002:a25:e90f:0:b0:dc2:232d:7fde with SMTP id n15-20020a25e90f000000b00dc2232d7fdemr670361ybd.13.1709067108474; Tue, 27 Feb 2024 12:51:48 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 27 Feb 2024 21:51:36 +0100 Message-ID: Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000e5f95d06126331fa" From: kontakt@beberlei.de (=?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?=) --000000000000e5f95d06126331fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey, On Wed, Feb 21, 2024 at 7:58=E2=80=AFPM Larry Garfield wrote: > Hello again, fine Internalians. > > After much on-again/off-again work, Ilija and I are back with a more > polished property access hooks/interface properties RFC. It=E2=80=99s 99= % > unchanged from last summer; the PR is now essentially complete and more > robust, and we were able to squish the last remaining edge cases. > > Baring any major changes, we plan to bring this to a vote in mid-March. > > https://wiki.php.net/rfc/property-hooks > > It=E2=80=99s long, but that=E2=80=99s because we=E2=80=99re handling ever= y edge case we could > think of. Properties involve dealing with both references and inheritanc= e, > both of which have complex implications. We believe we=E2=80=99ve identi= fied the > most logical handling for all cases, though. > > Note the FAQ question at the end, which explains some design choices. > > There=E2=80=99s one outstanding question, which is slightly painful to as= k: > Originally, this RFC was called =E2=80=9Cproperty accessors,=E2=80=9D whi= ch is the > terminology used by most languages. During early development, when we ha= d > 4 accessors like Swift, we changed the name to =E2=80=9Chooks=E2=80=9D to= better indicate > that one was =E2=80=9Chooking into=E2=80=9D the property lifecycle. Howe= ver, later > refinement brought it back down to 2 operations, get and set. That makes > the =E2=80=9Chooks=E2=80=9D name less applicable, and inconsistent with w= hat other > languages call it. > > However, changing it back at this point would be a non-small amount of > grunt work. There would be no functional changes from doing so, but it=E2= =80=99s > lots of renaming things both in the PR and the RFC. We are willing to do = so > if the consensus is that it would be beneficial, but want to ask before > putting in the effort. thank you for this proposal. there are some points i'd like to make into this discussion: * Thank you for the removal of $field, it was non-idomatic from a PHP POV. * I would prefer that the short syntax $foo =3D> null; be voted upon separately. Personally I think it could be confusing and is too close to a regular assignment for default value and I prefer not to have it and keep the rest of the RFC. * The magic of detecting if a property is virtual or backed is - like Rowan said - subtle. I would also prefer this to be managed via an explicit mechanism, by for example keywording the property as "virtual", instead of the implicit way with the parsing based detection. * As Doctrine project maintainer, we have had some troubles supporting read only properties for proxies. I would have hoped that with hooks I can overwrite a readonly property and "hook" into it instead by defining a getter, but "no setter". From my read of the RFC this would not be allowed and throws a compile time error. Could you maybe clarify why at least this special case is not possible? I didn't immediately get it from the RFC section on readonly as it only speaks about the problems in abstract. greetings Benjamin > > -- > Larry Garfield > larry@garfieldtech.com > --000000000000e5f95d06126331fa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey,


On We= d, Feb 21, 2024 at 7:58=E2=80=AFPM Larry Garfield <larry@garfieldtech.com> wrote= :
Hello again, fine Internalians.

After much on-again/off-again work, Ilija and I are back with a more polish= ed property access hooks/interface properties RFC.=C2=A0 It=E2=80=99s 99% u= nchanged from last summer; the PR is now essentially complete and more robu= st, and we were able to squish the last remaining edge cases.

Baring any major changes, we plan to bring this to a vote in mid-March.

https://wiki.php.net/rfc/property-hooks

It=E2=80=99s long, but that=E2=80=99s because we=E2=80=99re handling every = edge case we could think of.=C2=A0 Properties involve dealing with both ref= erences and inheritance, both of which have complex implications.=C2=A0 We = believe we=E2=80=99ve identified the most logical handling for all cases, t= hough.

Note the FAQ question at the end, which explains some design choices.

There=E2=80=99s one outstanding question, which is slightly painful to ask:= Originally, this RFC was called =E2=80=9Cproperty accessors,=E2=80=9D whic= h is the terminology used by most languages.=C2=A0 During early development= , when we had 4 accessors like Swift, we changed the name to =E2=80=9Chooks= =E2=80=9D to better indicate that one was =E2=80=9Chooking into=E2=80=9D th= e property lifecycle.=C2=A0 However, later refinement brought it back down = to 2 operations, get and set.=C2=A0 That makes the =E2=80=9Chooks=E2=80=9D = name less applicable, and inconsistent with what other languages call it.
However, changing it back at this point would be a non-small amount of grun= t work. There would be no functional changes from doing so, but it=E2=80=99= s lots of renaming things both in the PR and the RFC. We are willing to do = so if the consensus is that it would be beneficial, but want to ask before = putting in the effort.

thank you for t= his proposal. there are some points i'd like to make into this discussi= on:

* Thank you for the removal of $field, i= t was non-idomatic from a PHP POV.

* I would prefe= r that the short syntax $foo =3D> null; be voted upon separately. Person= ally I think it could be confusing and is too close to a regular assignment= for default value and I prefer not to have it and keep the rest of the RFC= .

* The magic of detecting if a property is virtua= l or backed is - like Rowan said - subtle. I would also prefer this to be m= anaged via an explicit mechanism, by for example keywording the property as= "virtual", instead of the implicit way with the parsing based de= tection.

* As Doctrine project maintainer, we have= had some troubles supporting read only properties for proxies. I would hav= e hoped that with hooks I can overwrite a readonly property and "hook&= quot; into it instead by defining a getter, but "no setter". From= my read of the RFC this would not be allowed and throws a compile time err= or. Could you maybe clarify why at least this special case is not possible?= I didn't immediately get it from the RFC section on readonly as it onl= y speaks about the problems in abstract.

greetings=
Benjamin
=C2=A0

--
=C2=A0 Larry Garfield
=C2=A0 larry@ga= rfieldtech.com
--000000000000e5f95d06126331fa--