Re: [RFC] Readonly Properties
| From: | Rowan Collins | Date: | Tue, 28 Oct 2014 14:04:36 +0000 |
| Subject: | Re: [RFC] Readonly Properties | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78426@lists.php.net to get a copy of this message | ||
Chris Wright wrote on 28/10/2014 09:46:
I would suggest something like this: public $foobar {The reason I opted for using var rather than having modifiers on both sides was because I wasn't sure what should be done with expressions like this: public $foo { private get; private set; } Is that allowed, and actually creates a private property? Or does the compiler detect it and give some kind of error? It feels like a bug in the syntax that the same information is included in more than one place, meaning it can express contradictions. -- Rowan Collins [IMSoP]get { return $this->bar * $this->foo; } private set($value) { $this->bar = $value / $this->foo }} ...where only a single visibility modifier is permitted on the left, and this is treated as the *default* visibility for the accessors, which are free to declare another visibility if they want - so the following would be equivalent: public $foobar {public get { return $this->bar * $this->foo; } private set($value) { $this->bar = $value / $this->foo }}