On 17/11/15 11:04, Rowan Collins wrote:
> If you look at the PSR-7 implementation I linked to earlier [1], there's
> no such boilerplate, just a single call to "clone $this", and PHP does
> it all for you. But that doesn't work with a simplistic definition of
> immutable like "mutable in constructor" or "mutable until non-null"; you
> need to be able to "freeze" an instance once you've set it up, or have
> privileged (private) methods which are allowed to mutate the properties.

read_only=true; ... after the value is set.

Switch off all the 'setter' magic once the object has been created, but
I still see a problem where this only really works with simple values?
If I've created a more complex object, while it's 'value' may need to be
fixed, how it's displayed may involve setting alternative defaults, so
one still needs to be able to set other variables in the object.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to