Chris Wright wrote on 28/10/2014 09:46:
I would suggest something like this:
public $foobar {
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 }
}
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]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php