I am confused by one thing about the RFC. There is a section for default
accessor implementations where you specify an accessor without a body,
however many of the examples omit the isset and unset accessors. I would
assuming that omitting an accessor would provide the automagic
implementation. If this is the case what is the need for the special
syntax? If this is not the case then what is the effect of omitting an
accessor?
Omitting get/set declaration (and body) makes the property read only or write only.
Omitting isset/unset has the same effect as declaring it without a body. This is described in the RFC under Automatic Implementations with this line:
Note that isset/unset implementations will always be provided if they are not defined or if they are explicitly auto-defined (as above).
I do see that omitting the setter creates a read-only property, however I
think the syntax would be less ambiguous and easier to use by introducing a
readonly
keyword:
class MyClass
{
public readonly $myProp {
// ...
}
}
This would also eliminate the need for additional syntax for default
accessors. There is one problem I see with this however, what happens when
a setter is provided for a readonly property?
If this has already been discussed, please accept my apologies and maybe
provide a link to the discussion.
This point of contention was discussed ad nauseam and nobody wanted the read-only/write-only keywords, they were removed from 1.1 -> 1.2
Please see this document:
Regards,
Philip
On Wed, Jan 2, 2013 at 6:36 AM, Clint Priest <
[email protected]> wrote: