Andrea Faulds wrote on 28/10/2014 14:08:
>On 28 Oct 2014, at 07:17, Jordi Boggiano<j.boggi...@seld.be> wrote:
>
>I like it, except for the fact that if you add a custom getter to a property suddenly it
becomes readonly unless you remember to add "; set" to the end of the block, right?
Well, no. If you choose to specify getters and setters, and only specify a
setter, of course it is read-only. It doesn’t make sense to have a getter and
no setter and yet expect a property to be writeable.
I think the problem is that the get and set annotations are serving
multiple purposes - to change the visibility, to define custom
accessor/mutator code, but also to declare whether certain actions are
possible at all. Since the default is for the property to be readable
and writable, the fact that adding "{ get; }" makes it readonly isn't
immediately intuitive, although it does makes sense once you think about it.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php