Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124509 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 E17A81A00B7 for ; Sat, 20 Jul 2024 12:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721478255; bh=WRgXE1ndatuAYYz+NjSeMSdC2VA/sUYPYdoYzgz1veY=; h=Date:From:To:In-Reply-To:References:Subject:From; b=RdoBOsAVK1tzmuX+ohK7/38FXvQ96qIxFYGsEppnWJwbOJGmPfnxwoLNt0P6TZA9h deVQ0jaoujEBhKMqfjuMmXliMnQ4pOp4pK2RvJXNJALPuBSmRhBHX/R8Ab03jkqGSR lASpmpzFdj3gqFO7gW8zfuN9Ugs1XLeavSHtxc0mTRZplgBLuSQmNTTvMMp5TqVs0X z1HaLgimhGB3Bm6uthiYJtdW4nPE3H8JeBiYO4kpak3lL+wiNjeayipCDvkKxpL3ad MSoRfMl6FQ+NwoydTKRlf4hffOVgNXiepMb/y/YDhLXkCZM8+WdbmRWFf9t1n4sTTi RVokpy5RkliTQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 76C4018002E for ; Sat, 20 Jul 2024 12:24:14 +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=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from BRA01-CPZ-obe.outbound.protection.outlook.com (mail-cpzbra01olkn2087.outbound.protection.outlook.com [40.92.97.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 20 Jul 2024 12:24:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EoXBesHOFMsJswnHsOizwvwEIt5IRdlEVKu0GBzInl3xN0TE4gBlJcuMWc/z9lYYy+V9gtq1/2l21nf6Rju19WO+epYrJPaKFBQDyB0PpAXJUEjcjhvgeLulShYLaSszEA3DOrwFhXk7ma2G3z3qLwatCewY5BVLsUfU7aZcE0d2ei71S1GdiYSaJkf39MDFvXFFWzef0x8HSTRD/HGW+wXj22TP8Xcxqa631Ifo1m9LqE/fiQbH2LrbQFEx/wS5j6S3GJlOEtkfn2mJQd+t2jmxofGIgiayx3QkeYq4474nLAFlGpgodVHWCjK6vVyLHd/EEEdRoW+UnrOCy4hJQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WRgXE1ndatuAYYz+NjSeMSdC2VA/sUYPYdoYzgz1veY=; b=D4lMKDhqRD29BgmNdPeCOwQtSQfdlvmTlNOqW+qKWLmop5aHUzFCT9GxSXKsrlBtKi3Dhx05ybxxbnl2go5MQfCwoHrLRNslQKjkDnu3PAwKRTDDARmJfmKf3fETeRCzcf5V4QwNEbuY9rU9I6H3OB9nPhocSPQPdSZmv3iKjkjSSzzpQZEVUVz1xm0PobbIXIQoTA+MCePorv7Qn0NLU4hzNJZmF4qM0rMnkIQcY9d7cvRUaeQC9JKhU559LW1yp0Mivggla+vWHwEbdRQSHnWoF+/JBJlZcz6VZ3a9i5sTNptyMIQeEkT1v2Ctvb5bPlvcPTV95ySIe7UhiMbntA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WRgXE1ndatuAYYz+NjSeMSdC2VA/sUYPYdoYzgz1veY=; b=N/Bgk/OLuHLbETGwxHKssvuOEcbeezEARAjK3EmxtYbWsksda1zMKVutRyrqWHvoNH7Fzs8V3SjJkEUTNDDOzbHhc7xwXTGhdNaNDbSVfphok0kqJHnbsLJHuQwTFIkP6iOQ4aHuhEAe5PJeGlwGWRIJ0UlGUPMN6W4hA7ai+KMxXHafLVNcBESO5KI5C1JrQF9xhz9SMV/9NuhQRZcEmOfy5DgW1kGPpzClH2DzIZWViQ2oGIS2jQeUs4V3BJeL241Dky5/7lvj78fJ6svod/6nmdVUpQffp7XxT9/ZogzrBzz0b5n4JmEwWUoql7TIWDpqbwWJyMGjNfy/lUuOcA== Received: from CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:1e4::5) by CP4P284MB2368.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:1af::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Sat, 20 Jul 2024 12:22:26 +0000 Received: from CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM ([fe80::3914:749c:31bc:e96d]) by CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM ([fe80::3914:749c:31bc:e96d%7]) with mapi id 15.20.7784.013; Sat, 20 Jul 2024 12:22:26 +0000 Date: Sat, 20 Jul 2024 09:22:19 -0300 To: php internals , Larry Garfield Message-ID: In-Reply-To: References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 X-Readdle-Message-ID: 5246c1c7-cd81-412b-99af-72683dbcae8e@Spark Content-Type: multipart/alternative; boundary="669bac00_44b1ab07_4d0" X-TMN: [FgUtlzQiLFXwFd+xU5Sone9UlCtZJL+j] X-ClientProxiedBy: CPXP152CA0012.LAMP152.PROD.OUTLOOK.COM (2603:10d6:103::24) To CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:1e4::5) X-Microsoft-Original-Message-ID: <5246c1c7-cd81-412b-99af-72683dbcae8e@Spark> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CP8P284MB2148:EE_|CP4P284MB2368:EE_ X-MS-Office365-Filtering-Correlation-Id: b29177e9-0bb3-4398-fd7e-08dca8b69dd7 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|19110799003|8060799006|440099028|4302099013|3412199025|56899033|1602099012; X-Microsoft-Antispam-Message-Info: hF63pxbBegvPorrVnaN/VYhvaFgkW3vcs6qcREc6wNxoStN7WJuGnyzGLpwHFnNiUwhegSh/0RUV4uFTLChwBE4IXovD+VTDSgD+YAIzMlfeiXar1+1NR9FSlzDr7tdfCaiX7Yg5+nGzRIgwhg32WeiAl4fKJA7O3AWWKi51FL4VUxZC1xjzOpxsTzL0csbEoXTKc6owoGO/8cw0wAsh8khm3gzTe6JzTKZFSD/pL9KelxP8OgV63tJ1DPwJ4dw0bTuRts3nJtGI83ZtQY50RqvWJow3B05y0aUpBcdXYOde3IZu3BjwxDorQhJg7tAxXHDIueimbwW6063TZNTGs7DQDqxILrbCbMn8RSOVWtECARFrEKkt9K9a0qQkGzYksuIstU2umVJCye+X7ACTe+8ptOqFhc2wpVBLlnigPmGHXKPEm4cYyJiqpshN5z78HoBf8+o5JHVKBPx6Zb0tCACdZ3OTLD9uvmSiC0dA20dbLGAuD7TmtwbZvqObzypUo2OgzO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GRNcmo2K1FtSTdrZGp6NW5henh3Zkk5K0Fpc3d5cS80QXRXd3p5ajdN?= =?utf-8?B?NXpjWlJzL1AyTVdUVHpXbUhTK2JCS1FzeHRJVFNsVjRuTlR4eGtSY2tUKy83?= =?utf-8?B?WDRoQzYwd21CbkVFaWl0Qjd1cFhVeHZxTCtnZXpyMjQ2NSswaFhBK3NNamVG?= =?utf-8?Q?8Umf/d1v+jZh+Zlgx+Ua?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b29177e9-0bb3-4398-fd7e-08dca8b69dd7 X-MS-Exchange-CrossTenant-AuthSource: CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 12:22:26.8487 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CP4P284MB2368 From: rodrigo.vieira92@outlook.com (Rodrigo Vieira) --669bac00_44b1ab07_4d0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Will the alternative syntax on hook not even be put to a vote=3F I think the =22prefix-style=22 syntax breaks the standard property signat= ure template that exists since PHP 5=21 Natural syntax: =24; With prefix-style: (set) =24; This introduces a syntax that is totally unexpected to natural reading. I= n my opinion, pretty ugly. What about some static code analysis tools=3F What about using regex to p= arse code and syntax in PHP (which takes a lot of work to build) for exte= nsions used in IDEs like VSCode, IntelliJ, etc.=3F To parse Property Hooks, a lot of time and work will already be spent ada= pting to the new syntax, and now this as well=3F Why not take advantage o= f the new Property Hooks syntax newly implemented=3F Implementing visibility in the hook, which can be now the default API of = the properties, would further enhance the syntax of Property Hooks, which= in my opinion is one of the best features of PHP in the past five years.= If more operations on Hooks are implemented in the future, what is the us= e of this syntax=3F How could it be used=3F =46or example, an operation t= hat is called only when a property is first set: =60init=60 hook. public =24prop =7B =C2=A0 =C2=A0private init =3D> //...set a default initial value here =7D A hook called 'push' only for arrays, would solve some semantic problems = and make it clear to separate the set operation (set values of an array) = vs push only one item to the array as I showed in the example above. What about other operations that are already common when we use magical m= ethods in the future: unset, isset, etc.=3F In the Property Hooks R=46C, it was mentioned that more hooks may be adde= d in the future. It may be a default behavior for developers to want to override all magic= methods for properties using Property Hooks. =46or now there is only get= and set, but what about unset, isset, etc=3F How is it to define the vis= ibility for this in the future=3F public private(set, unset).... =3F=3F Where would new operations beyond the =60set=60 will enter this syntax=3F= Cheers, Rodrigo Vieira Em Jul 19, 2024, 10:18 PM -0300, Larry Garfield escreveu: > On Wed, May 29, 2024, at 2:15 PM, Larry Garfield wrote: > > As promised, Ilija and I offer this revised version of asymmetric vis= ibility. > > > > https://wiki.php.net/rfc/asymmetric-visibility-v2 > > > > It's still essentially the same as last year's version, but with a fe= w > > adjustments and changes: > > > > * readonly properties are now supported in a logical fashion. > > * We've brought back the abbreviated form, as public-read, something > > else set is the most common use case. > > * The section on magic methods has been greatly simplified. The > > implementation itself hasn't changed, but the explanation is a lot le= ss > > confusing now. > > * We've explained how aviz interacts with hooks (they don't, really) > > and with interface properties (in the obvious way), which didn't exis= t > > at the time of the last draft. > > * We've added a section with examples of how aviz is a concrete > > improvement, even in a world with readonly and hooks. > > * We've added a section discussing why the prefix-style syntax was > > chosen. > > Hi folks. After a side quest to polish off hooks, we're nearly ready to= bring aviz to a vote. > > We've made one change since we last discussed it: Specifically, Ilija r= ealized that =5F=5Fset's behavior is already inconsistent, so supporting = it for aviz properties with invisible set would make it even more inconsi= stent, not less. =46or that reason, we've changed the =5F=5Fset behavior = such that a non-readonly aviz property will not trigger =5F=5Fset. =46urt= her details are in the R=46C, but in short, all of the use cases for that= behavior now have better alternatives, such as property types, hooks, an= d aviz itself. So there's really no point to falling back to =5F=5Fset in= edge cases. > > https://wiki.php.net/rfc/asymmetric-visibility-v2=23interaction=5Fwith=5F= set=5Fand=5Funset > > Baring any new developments, we plan to start the vote early next week.= > > Cheers. > > --Larry Garfield --669bac00_44b1ab07_4d0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Will the alternative syntax on hook not even be put to a = vote?

I think the "prefix-style" syntax breaks the standard property si= gnature template that exists since PHP 5!

Natural syntax:

<visibility> <types> $<name>;

With prefix-style:

<visibility> <visibility>(set) <types> $<name>;

This introduces a syntax that is totally unexpected to natural reading. In = my opinion, pretty ugly.

What about some static code analysis tools? What about using regex to parse= code and syntax in PHP (which takes a lot of work to build) for extensions= used in IDEs like VSCode, IntelliJ, etc.?
To parse Property Hooks, a lot of time and work will already be spent adapt= ing to the new syntax, and now this as well? Why not take advantage of the = new Property Hooks syntax newly implemented?

Implementing visibility in the hook, which can be now the default API of th= e properties, would further enhance the syntax of Property Hooks, which in = my opinion is one of the best features of PHP in the past five years.

If more operations on Hooks are implemented in the future, what is the use = of this syntax? How could it be used? For example, an operation that is cal= led only when a property is first set: `init` hook.

public $prop {
   private init =3D> //...set a default initial value here
}

A hook called 'push' only for arrays, would solve some semantic problems an= d make it clear to separate the set operation (set values of an array) vs p= ush only one item to the array as I showed in the example above.

What about other operations that are already common when we use magical met= hods in the future: unset, isset, etc.?
In the Property Hooks RFC, it was mentioned that more hooks may be added in= the future.

It may be a default behavior for developers to want to override all magic m= ethods for properties using Property Hooks. For now there is only get and s= et, but what about unset, isset, etc? How is it to define the visibility fo= r this in the future?

public private(set, unset)....
??
Where would new operations beyond the `set` will enter this syntax?

Cheers,
Rodrigo Vieira
Em Jul 19, 2024, 10:18 PM -0300, Larry Ga= rfield <larry@garfieldtech.com> escreveu:
On Wed, May 29, 2024, at 2:15 PM, Larry Garfield = wrote:
As= promised, Ilija and I offer this revised version of asymmetric visibility.=

https://wiki.php.net/rfc/asymmetric-visibility-v2

It's still essentially the same as last year's version, but with a few
adjustments and changes:

* readonly properties are now supported in a logical fashion.
* We've brought back the abbreviated form, as public-read, something
else set is the most common use case.
* The section on magic methods has been greatly simplified. The
implementation itself hasn't changed, but the explanation is a lot less
confusing now.
* We've explained how aviz interacts with hooks (they don't, really)
and with interface properties (in the obvious way), which didn't exist
at the time of the last draft.
* We've added a section with examples of how aviz is a concrete
improvement, even in a world with readonly and hooks.
* We've added a section discussing why the prefix-style syntax was
chosen.

Hi folks. After a side quest to polish off hooks, we're nearly ready to bri= ng aviz to a vote.

We've made one change since we last discussed it: Specifically, Ilija reali= zed that __set's behavior is already inconsistent, so supporting it for avi= z properties with invisible set would make it even more inconsistent, not l= ess. For that reason, we've changed the __set behavior such that a non-read= only aviz property will not trigger __set. Further details are in the RFC, = but in short, all of the use cases for that behavior now have better altern= atives, such as property types, hooks, and aviz itself. So there's really n= o point to falling back to __set in edge cases.

https://wiki.php.net/rfc/asymmetric-visibility-v2#interaction_with_set_and_= unset

Baring any new developments, we plan to start the vote early next week.

Cheers.

--Larry Garfield
--669bac00_44b1ab07_4d0--