Re: [RFC] Readonly Properties

From: Date: Tue, 28 Oct 2014 14:08:10 +0000
Subject: Re: [RFC] Readonly Properties
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-78427@lists.php.net to get a copy of this message
> On 28 Oct 2014, at 07:17, Jordi Boggiano <j.boggiano@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. > How about this instead for readonly: > > public $foobar { > get { return $this->bar * $this->foo; }; readonly > } > > And if the flag isn't there, set is implicitly present. This is really confusing and I don’t think it’s a good idea. -- Andrea Faulds http://ajf.me/

« previous php.internals (#78427) next »