Re: [RFC][Vote] Asymmetric Visibility
| From: | Thomas Nunninger | Date: | Tue, 10 Jan 2023 17:19:42 +0000 |
| Subject: | Re: [RFC][Vote] Asymmetric Visibility | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119254@lists.php.net to get a copy of this message | ||
Hi,
I was looking at the current vote of this RFC and I stumbled upon Theodore's remark that the RFC feels unfinished as it can't be used in conjunction with readonly properties/classes.
The RFC disallows (for the time being) the mixing of readonly with explicit asymmetric visibility. And I was happy about it. Thus I didn't feel the need to comment about it so far.
The main motivation given in the readonly RFC was value objects. And as far as I understand, one of the main reasons was to reduce boilerplate code (esp. public getters). readonly works fine for value objects. But looking at entities, there is no solution so far. Thus I still (might) need to provide public getters. And because of the limitations of readonly, there was/is a need for asymmetric visibility.
I doubt, there would be any need for readonly if we would have had asymmetric visibility first. And (using asymmetric visibility) I assume, developers should be able to ensure that a property is 1. only initialized once, 2. inside the limited scope of a class, and 3. not overwritten during the lifetime of the object. I'd be interested in a use case where you would really like to ensure this on the engine level.
To go one step further, I would even ask the heretical question if we should discourage/deprecate readonly once we have asymmetric visibility. ;-)
Regards
Thomas
Am 07.01.23 um 00:37 schrieb Larry Garfield:
I am hereby opening the vote on the Asymmetric Visibility RFC: https://wiki.php.net/rfc/asymmetric-visibility Voting will be open for 2 weeks. While we would certainly prefer if everyone voted in favor, for those who vote against the authors kindly request that you indicate why, using the second poll question or comment section afterward. Thank you.