Re: Analysis of property visibility, immutability, and cloning proposals

From: Date: Sun, 10 Jan 2021 10:54:42 +0000
Subject: Re: Analysis of property visibility, immutability, and cloning proposals
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-112829@lists.php.net to get a copy of this message
On 10 January 2021 01:24:38 GMT+00:00, "G. P. B." <george.banyard@gmail.com> wrote: >Moreover, asymmetric visibility does not prevent mutating an object by >calling the constructor once again as follows: >$obj->__construct(...$args); That's pretty trivial to work around: mark the constructor private and provide one or more public static methods that call it. That's actually a pretty common and useful design in its own right. It's also something that could probably be banned at the language level. I seem to remember it being discussed before, but the details aren't quite trivial because you need to allow parent::__construct etc. I'd rather spend the time to work out those details than design the rest of the language around it being possible, if it's really that much of an issue. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#112829) next »