> On 24 Oct 2014, at 12:59, Andrea Faulds <a...@ajf.me> wrote: > >> >> 2. If the aim of this RFC is to replace the getFoo() pattern with the use of >> "readonly public $foo" properties, a primary difference will be that a >> getFoo() method can be declared in an interface, whereas a "readonly public >> $foo" property cannot be. Thus code making use of interfaces will not be >> able to employ this feature. And I don't think that allowing properties in >> interfaces is reasonable at this point, because the implementations will be >> limited to simple-storage properties - only with more comprehensive property >> accessor support would implementations be allowed to use more complex >> backing code. > > Right, interfaces currently can’t declare properties and I’m not going to > change that in this RFC. If I revisit getters and setters, that would be > changed. Still, I think there is usefulness to this without interfaces… it’s > just more limited, sadly. > > It would work quite well with getters and setters and interfaces, if later > added. Within interfaces, readonly could be used to avoid compelling > implementing classes to support writing: > > interface Point { > public readonly $x, $y; > } > > But without preventing implementing classes from supporting it.
I added a little Future Scope section on this: https://wiki.php.net/rfc/readonly_properties#puture_scope -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php