Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120368 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15194 invoked from network); 20 May 2023 12:05:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 May 2023 12:05:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B2B721804AA for ; Sat, 20 May 2023 05:05:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 20 May 2023 05:05:26 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-4f3af4295ddso1679931e87.2 for ; Sat, 20 May 2023 05:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684584324; x=1687176324; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZHtHbwL+VxZ3LBMFSZFRds9n2vsU4v2QGX69oDYsBL0=; b=Zv6Yaw6E7ZmAFO4NBhDty84acLBbWXE+egd0tMIGjoA5Iq6i0AvVat87ht85bkjIJZ xQhmhQBnXeza5/TOZq9xNyqEqiEH7ty2YGOdzg+dEgYTcJyy5MWXdy4PSrMvUBYeWyBA d6dklqhJBro1DaFgytCZg7lb8IaylKuTpDfXY7G7PgtQ9h5jW8Dc0B2TcrN4cBZT9Ill AFwXG+UYeOfzITqGMd7qGYTG9z6pV/I2gscel1p94Q3qfW2/iE9kD2D564hLBqkTBrb3 LTuNLNQMP/FAaBUlYRxGgU5nJICTI01b2+7oimUQfBALpl/iVuKeA+0b9vepoxQ4hvld qUcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684584324; x=1687176324; 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=ZHtHbwL+VxZ3LBMFSZFRds9n2vsU4v2QGX69oDYsBL0=; b=cq2T6dXllxgPPbOryzRRWIMQvHGFG89AAIZKd/rMnpPL7bCDlJL2JHr1ra6se0E+Eg Pps84N2j/6DmJWPkyAL2zjnuma1ceseIwbYv17+B/KyAdo/ht1QRiU3mUQFlhu+8Q5Xv 7uRfq7Bo5/kWDWhmbUV9kicheM//iUU2fZRrLiFhKZtGuDKL8rQMyohX2ebZsyotLx0r WcXTX4sEgD/9H7PGNyZI1Lg+jE/bGI41qGWndKBipHN5ezQIuxiYrVFYGRlNwi5TjvX6 rZaYc3Lsbi1USL9eOlmp8YqnAuKZ0lG+uN1BpHXp2Murth68owRwK3eGTduSgJ6xKEmt Ha8Q== X-Gm-Message-State: AC+VfDx297PbMdH0q3xIzmD+xLHjezqCJ5Zy4AORXACQLZ9pKNvNbdN/ XEhrTK2lKYUN6htN6GkgtkH86dC9Nn+oIuPvKV8+lr7hoEo= X-Google-Smtp-Source: ACHHUZ6xKRAmMFxardBAQ+MUuFDtIGxoNYfu/bV2VQvkQCKACQwVVL82Wbkt/QP+UbVTdfw9Dy+owCEw15dkwdxDv+Y= X-Received: by 2002:ac2:5283:0:b0:4f3:ba58:cf2a with SMTP id q3-20020ac25283000000b004f3ba58cf2amr87236lfm.27.1684584324071; Sat, 20 May 2023 05:05:24 -0700 (PDT) MIME-Version: 1.0 References: <641b1ca0-d33f-4f38-ae64-81b4abce24da@app.fastmail.com> <6b1fe5c4-fa92-42c0-b388-32cdda0a27a2@app.fastmail.com> In-Reply-To: <6b1fe5c4-fa92-42c0-b388-32cdda0a27a2@app.fastmail.com> Date: Sat, 20 May 2023 09:04:47 -0300 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000003b07ab05fc1eda94" Subject: Re: [PHP-DEV] [RFC] Property hooks, nee accessors From: ericklima.comp@gmail.com (Erick de Azevedo Lima) --0000000000003b07ab05fc1eda94 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I can't wait! Especially because I'm heading a modernization of the systems in my organization and my plan is to use the cutting edge PHP version for it. Currently our internal "framework" uses PHP 7.4, but with a PHP 5.6 coding style. Again: I can't wait! I can't do much but thank everyone who spends their time to make PHP evolve= . Thank you all! Regards, Erick Em sex., 19 de mai. de 2023 =C3=A0s 17:48, Larry Garfield escreveu: > On Mon, May 8, 2023, at 9:38 PM, Larry Garfield wrote: > > Ilija Tovilo and I would like to offer another RFC for your > > consideration. It's been a while in coming, and we've evolved the > > design quite a bit just in the last week so if you saw an earlier draft > > of it in the past few months, I would encourage you to read it over > > again to make sure we're all on the same page. I'm actually pretty > > happy with where it ended up, even if it's not the original design. > > This approach eliminates several hard-to-implement edge cases while > > still providing a lot of functionality in one package. > > > > https://wiki.php.net/rfc/property-hooks > > Hi folks. Based on feedback we've made a few smaller changes to the RFC. > > Changelog: > > * The sections describing isset/unset and magic methods have been > rewritten to be clearer. Nothing changed in the actual behavior, it is n= ow > just explained better. > > * Contravariance on the "set" type is now enforced. Ilija figured out ho= w > to make it work. :-) That means a non-contravariant type on the set hook > will now throw an error, as expected. > > * After extensive discussion with Nicolas Grekas, we've decided to allow > references in a very narrow case. Specifically, on a *virtual property* > (one that has no inherent backing store), you may implement a `&get` hook > instead of `get`, and the value it returns will be returned by reference, > and may be captured using $foo =3D& $bar->baz; We determined that it is = a > bit better for BC (in the rare cases that you actually want to get a > reference to a property, you can, even if it requires a little more work)= , > doesn't break anything else, and is consistent with the way `&__get` > behaves. __get/__set are basically "anonymous virtual properties", so no= w > they behave the same way. By the same token, setting by reference is sti= ll > not allowed, which is also true for __set today. > > As there was no other interest in it stated, we're going to hold off on a= n > `unset` hook at this time. Given the earlier discussion I think there is= a > valid use case for it, so it would be a worthwhile follow up RFC in the > future, but for the moment we want to keep it simple. > > There also doesn't seem to be much interest in specifying which hook gets > the double-shortened syntax. I can see the argument for it, but it would > increase the typing in a common case for an unclear benefit, and only one > person expressed any interest in it. So we're not going to go that route= . > > There's two items still pending. > > 1. Ilija is experimenting with the `parent::$prop::get()` syntax, to see > if either the syntax or implementation can be simplified. There may or m= ay > not be a small change here as a result, TBD. > > 2. Ilija still has to verify that foreach() can work with virtual > properties as the RFC currently describes. The implementation details ar= e > thornier than they seem, so that still needs some validation and testing. > > Assuming both of those get sorted out soon, we will probably call a vote > around the end of the month, give or take. > > Cheers. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --0000000000003b07ab05fc1eda94--