Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122449 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 DCC8D1ACEBF for ; Thu, 22 Feb 2024 00:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708560412; bh=kwjhsQp0chgiZu1cB92M9gO9Mo/xVHm6YL1jgksRN6A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CNCo/axu9ufxSRby5PwQYvKkwyHf46MF2NycSHnrq34fQvEZkX/o5Z9x9AXPnVLE3 Vi9eJexFfpWwwoiSA3ELDUCVBAOiMtmZOWSXsO0vJ4WluXyG8zssd1NX+SaYgbDCXF 5lDZSaL/U8UzRa3scjYt7rvDsd4vlhLDdg4Pq1k3roll0dn3IRpMempR+Oh1z0UD/D TCHTKSQSleY846iQMoQfsIuqiRzaP8MA65XPopHVQleXwouUjwCg46d+sEmXpyNNdf s5wROdwARdt0HGfBJ/XDMDfpdwsFDjP1Rf9Qp9n5bSbPaSmDWynAnM3mlq5m7HtPNV FTG9ffIavZWvg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AB682180071 for ; Thu, 22 Feb 2024 00:06: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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,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 ; Wed, 21 Feb 2024 16:06:48 -0800 (PST) Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-59cbf204d52so879930eaf.1 for ; Wed, 21 Feb 2024 16:06:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708560402; x=1709165202; 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=cQC8SksbdOLBnWCqLPIL33Dh5x5Iynlx5Ao8IauMa5U=; b=WMq75lc/CEoP7fDToPMMFRocnsU1t8o9qK7meygE9XR5Y+8a+i0ybDVBYNhrocN0rY 4X2V1hevlkaSzLRcEvjsvIlGzTB1LuuQODYnfUAYD/xHj1NAjQemNBTNcadEgn9ajPvU M2iGI1TQ2bpcTATOkkdkzJzjMqnPl+CVoeA6/+ujPd0OpGlI/bZt/ijyD9WxfPWJP9ca D6W0yd5xNzzw966Iff+mGTscZjScL/ioJFfs/6QmltX2AQWvSm7YHbNQ3ELvsAg7RjG2 fqzZosQzuKgmqCnfUb4d162ETCtgMhnx5YiIYWgun+nKc1IVSSd8rpT04z0uUwnHDnys TmrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708560402; x=1709165202; 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=cQC8SksbdOLBnWCqLPIL33Dh5x5Iynlx5Ao8IauMa5U=; b=FkLFy/xvk7OXftqo+13AJZK7rwyGJaTtWGGkCpN2Ov9EGG7HrpalOMo2KcwYBWpfrT /sHCfgY4ECiIC6sFz5T54Bj2Dp0WhjL987W/17ezpeislJwwx75nF76D0LXxqdNTj7Jl h4hE1L5mHS+sWu+1aIbMGLNTiwe+zxaEwUpTcYTxnm8HZRqliygWLS01jTwJ1Ylygr1y Ks5aLWnCEOiwxFWFmX122yopCScRz/WZz9MsPCarHkPe9FeW9lI6eYu0JdJTc66WRyHn 8MsY5nvUd2Kw0bx3ScAYjW2Vd657DT8hzQrvE6v5tyQ6AOi4h1JuS1k9WGxd9iKh+RLC Ol1w== X-Gm-Message-State: AOJu0Yxbot8eN8U2GvFOPYfgvYpHk7ckA0vf5tBI5mRw+fYsrMV4brcr grQxkWCpm65ZGIMxnuGosUvEj726U6W3rM8S0/JW4MFkyNrhdf73Dg+TsG1U5rAwHVLfBiUpCnq VwFOyVxmjIMhZd8cfvEr/YYwOpYMTG6uMqOk= X-Google-Smtp-Source: AGHT+IH7Z7UB7JU4x5N+1Ke7dtiw7aA2m2f9K5MigOIYwZkhGF1Fo0JRbyWuQlqZ8NYoFJMaC8BqUQOi8i9l0SWhUFw= X-Received: by 2002:a05:6870:6125:b0:219:7fc1:bc97 with SMTP id s37-20020a056870612500b002197fc1bc97mr17190670oae.4.1708560402368; Wed, 21 Feb 2024 16:06:42 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 21 Feb 2024 21:06:06 -0300 Message-ID: Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000dc4ddd0611ed3701" From: deleugyn@gmail.com (Deleu) --000000000000dc4ddd0611ed3701 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2024 at 3: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. > > -- > Larry Garfield > larry@garfieldtech.com > This is a long, huge and comprehensive work, congratz to the authors. It clearly shows that so much thought and work has been put into it that it makes me cautious to even ask for further clarification. > Javascript have similar features via a different syntax, although that syntax would not be viable for PHP Why not? ``` final class Foo { public string $bar; public function get bar(): string { // custom getter } public function set bar(string $value): void { // custom setter } } ``` It feels quite a natural syntax for PHP and from someone oblivious to the internal work, it appears to be a slight marginal change to the existing RFC. Given the extensive work of this RFC, it seems pretty obvious that this syntax will not work, I just don't know why. --=20 Marco Deleu --000000000000dc4ddd0611ed3701 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Feb 21, 2024 at 3:58=E2=80=AF= PM Larry Garfield <larry@garfi= eldtech.com> wrote:
Hello again, fine Inte= rnalians.

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.

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

This is a long, huge and comprehensive wo= rk, congratz to the authors.

It clearly shows that so mu= ch thought and work has been put into it that it makes me cautious to even = ask for further clarification.=C2=A0

>=C2=A0Jav= ascript have similar features via a different syntax, although that syntax = would not be viable for PHP

Why not?
```
final class Foo
{
=C2=A0 =C2= =A0 public string $bar;

=C2=A0 =C2=A0 public funct= ion get bar(): string
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 // custom getter
=C2=A0 =C2=A0 }

<= div>
=C2=A0 =C2=A0 public function set bar(string $value): void
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // custom setter
=C2=A0 =C2=A0 }
}
```

It feels quite a natural syntax for PHP and from someone oblivious t= o the internal work, it appears to be a slight marginal change to the exist= ing RFC. Given the extensive work of this RFC, it seems pretty obvious that= this syntax will not work, I just don't know why.

--
Marco Deleu
--000000000000dc4ddd0611ed3701--