‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, May 4th, 2021 at 6:33 AM, Nikita Popov nikita.ppv@gmail.com wrote:
> Hi internals,>> I'd like to present an RFC for property accessors:>> https://wiki.php.net/rfc/property_accessors>> Property accessors are like __get() and __set(), but for a single property.>> They also support read-only properties and properties with asymmetric>> visibility (public read, private write) as a side-effect.>> The proposal is modeled after C#-style accessors (also used by Swift), and>> syntactically similar to the previous>> https://wiki.php.net/rfc/propertygetsetsyntax-v1.2
> proposal.>> While I put a lot of effort into both the proposal and the implementation,>> I've grown increasingly uncertain that this is the right direction for us>> to take. The proposal turned out to be significantly more complex than I>> originally anticipated (despite reducing the scope to only "get" and "set">> accessors), and I'm sure there are some interactions I still haven't>> accounted for. I'm not convinced the value justifies the complexity.>> So, while I'm putting this up for discussion, it may be that I will not>> pursue landing it. I think a lot of the practical value of this accessors>> proposal would be captured by support for read-only (and/or private-write)>> properties. This has been discussed (and declined) in the past, but>> probably should be revisited.>> Regards,>> Nikita
Hi,
Thank you for the effort put forth in this RFC. I have a few questions
after having read it.
Will these properties work with the property_exists() function? I don't
see it mentioned in the RFC, and seeing as how the function does not
work with properties defined in __get() and __set(), the answer to this
isn't obvious to me.
The RFC also mentions that calling isset() on a write-only property will
throw an Error exception. Should a new function along the lines of
property_is_readable(), which returns true if the property is readable
in the current scope, (and possibly its mirror function
property_is_writable()) be introduced? Going through the Reflection API
feels overly verbose and error prone to find out if a property is readable/writable.
- Trevor