Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122452 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 CE1AF1ACEBF for ; Thu, 22 Feb 2024 11:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708600961; bh=dfqCgKnu/wkcM52dHUrIt/YUbeVruwIAN3rbWsFRHcc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Daeqbt8oOPKR5F+ZbaWNzMd/idKkQB4U7OqtfB2pS2LyPw2IAbCcE4CZLTNfqtl7E 5ArAzQMpDopOjFbACZMJveim7qFneIor5DocljAtJw9iPnmlQ1IPt70pmzn3u/wuQR OELXJAfzGwbcOmY2Tdh3LxYiWlaiEgC+GLiIwQOsQeLqN5yE/3u1YS/+pQ6UAtAj5Y /ZdkElPdl4eTxHN0W/lY4JvLrn+KF/ZR7DjW63x7tr6yoFraaW2Fdj53+wPIKGtuV7 T0s4rVolVlTTPIQbMVn5AO7bxl/Il053PIIt3rikRircIxKjksnZt18ZDJieJS45mi 1KCvie3ONE43g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 01EA518006A for ; Thu, 22 Feb 2024 11:22:41 +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-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 ; Thu, 22 Feb 2024 03:22:40 -0800 (PST) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-299540b4d18so3461290a91.1 for ; Thu, 22 Feb 2024 03:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708600954; x=1709205754; 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=6viTEhIfH3mWRns/JCGV0AcUmVAtOZX24C9aJnQDe7Q=; b=f1+dWPdjcnWzzCcNJ5uqynmp5OR3kv1ZrjLnUaWfhOy1J6fyocKKEjJeL6HKeCOSpc TVyqfoHLtErrf6Eyh4jh3HhyZuPfxh8yc7xhcPz0evrYpXnV1TqfA/Y0j5rn8SCkhRw7 lXT+Ak2gnaHSMznbZvBp/zrpFpoqvX1Pdp7eFoxvLYCBvnJ+mV82X2UMyR9zXWmZf0m1 Di/xhuFtU1paxa4Zb/oFjtkye2eAX3JNqrJvXGvGuKYE/1UFU2MVrUXxobiyiEPN1w5Z LlBzZmCGybJZZwaovcNpoNuAxEURllI1+oVN7pDL3tCh0ul9X6op/CxQlspg8sccFiWl bKqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708600954; x=1709205754; 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=6viTEhIfH3mWRns/JCGV0AcUmVAtOZX24C9aJnQDe7Q=; b=IFaI9xQEN1LZY6q/1klD7Hexcsmijui1KHKUSGg+PhiW0NvDhlOxsKilz5qIRz1FhE Q+Mu7WN+5KcvPLRtdXBD4bVbmPHN2w5uPmAbapxm4zJo87vPe5liTpJx/y5dOS2QwVkE q9VvWSwkIOGakgnEUPjIhKo+gx1dZ3osN+uvxvGo/QrplyQKZ5IHCc2aG47H/5N4Gsxb ctXIHZG17HF3ZFPewdT7msR8cxdJ+ElTQZYwym350+oxFVfzPk9//G2T7+OtTjyirex0 Zn8P43JGb2OpEsZQJaUyTjxJUsbaLFoLtubYKApj1HTNQHBJMJdRNN3UJPm2FQg6ZJ2j DsXg== X-Gm-Message-State: AOJu0YzPxwhifIL9MKKyOK64yO/zdINewphFGayoxG/86WeEZiio+vDF 2LeSE8ol4m3xayBuyguADOi+fZLPE/8tUIF4zCQCgJoOb/JL3wywkQyjn1gshYwRL69VWrHe6rB rq1AD0RokC9b06pNH5BAVFrLjGiRLMfDmIntxWQ== X-Google-Smtp-Source: AGHT+IGvWh2bpznuL7Q8QCv4yk4obbPWtBsJ5HszPENngVCi4+kZm2MYVk9jU43gKQIMeWnU27uf8daNa0kS8mCNdVo= X-Received: by 2002:a17:90b:1d09:b0:299:3f36:48e3 with SMTP id on9-20020a17090b1d0900b002993f3648e3mr13833014pjb.11.1708600954076; Thu, 22 Feb 2024 03:22:34 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Feb 2024 11:22:22 +0000 Message-ID: Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000ee43240611f6a889" From: fenniclog@gmail.com (tag Knife) --000000000000ee43240611f6a889 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 21 Feb 2024 at 18:56, 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 I remember the previous RFC. cant remeber why it was decline, but i hope this one passes, I know the PHP community has been asking for native getter/setters instead of __get __set for a while, since 7.0 was released at least. A few things i was interested to get the idea around. Was it thought about for the set{} for it to return the value to set the property to instead implicitly setting its own field? eg ``` public string $name { set { return usfirst($value); } } ``` Where the value returned in the set is what the property will be set to? --000000000000ee43240611f6a889 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, 21 Feb 2024 at 18:56, Larry Garfield <larry@garfieldtech.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">Hello again, fine Internal= ians.

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

I remember the previous = RFC. cant remeber why it was decline, but i hope this
one passes,= I know the PHP community has been asking for native getter/setters
instead of __get __set for a while, since 7.0 was released at least.=C2= =A0

A few things i was interested to get the idea around= .=C2=A0
Was it thought about for the set{} for it to return = the value to set the=20 property=20 to=C2=A0
instead implicitly setting its own field?

<= div>eg

```
public string $name {
=C2=A0= =C2=A0=C2=A0 set {
=C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 return us= first($value);
=C2=A0=C2=A0=C2=A0 }
}
```
Where the value returned in the set is what the property will = be set to?
--000000000000ee43240611f6a889--