> > I'd like to open the discussion on readonly properties: > > https://wiki.php.net/rfc/readonly_properties_v2 > > > > This proposal is similar to the > > https://wiki.php.net/rfc/write_once_properties RFC that has been > declined > > previously. One significant difference is that the new RFC limits the > scope > > of initializing assignments. I think a key mistake of the previous RFC > was > > the confusing "write-once" framing, which is both technically correct and > > quite irrelevant. > > > > Please see the rationale section ( > > https://wiki.php.net/rfc/readonly_properties_v2#rationale) for how this > > proposal relates to other RFCs and alternatives. > > > > I plan to open voting on this RFC soon. I don't think there's anything > technical left to address here, the discussion mostly comes down to a value > judgement. I think everyone has made their position regarding that clear... >
Actually, we talked off the list about a way to possibly make this work with __clone(): We could allow __clone to have one argument, the object being cloned. And when the signature declares this argument, then all readonly properties would be set as uninitialized on $this. A typical __clone function would look like this with readonly properties: function __clone(object $original) { $this->readonlyProp = clone $original->readonlyProp; } That would turn my vote into a +1 if that could be made to work! Cheers, Nicolas