Re: [RFC] Property write visibility
| From: | Nikita Popov | Date: | Tue, 30 Jun 2020 07:59:22 +0000 |
| Subject: | Re: [RFC] Property write visibility | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110792@lists.php.net to get a copy of this message | ||
On Mon, Jun 29, 2020 at 11:43 AM André Rømcke <andre.romcke@gmail..com>
wrote:
> Good morning Internals,
>
> I'd like to start discussion on a new RFC proposing a way to be able to
> (optionally) specify property
> write visibility, separate from read:
>
> https://wiki.php.net/rfc/property_write_visibility
>
> This enables readonly, write-only and immutable like semantics for PHP's
> properties.
>
> These are the common use cases where users tend to resort to magic methods
> or setter/getter
> methods. This proposal will as such avoid unnecessary boilerplate, makes
> coding easier and more
> ergonomic, and in the case of magic method usage improve performance.
>
I think this is a good direction to explore, but would recommend delaying
it until PHP 8.1. As the RFC and discussion note, the design space here
overlaps significantly with both readonly/immutability and property
accessors. We should take enough time to consider these
alternatives/extensions as well, to ensure that we don't end up with
multiple distinct and possibly incompatible mechanisms. We don't have that
time before PHP 8.0 feature freeze.
Regards,
Nikita