Re: [RFC][DISCUSSION] - Disallow Multiple Constructor Calls

From: Date: Tue, 17 Jan 2017 20:52:40 +0000
Subject: Re: [RFC][DISCUSSION] - Disallow Multiple Constructor Calls
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-97831@lists.php.net to get a copy of this message
On 1/17/2017 9:48 PM, Nikita Popov wrote: > Without putting a lot of though into this, the restriction sounds > reasonable. > > However, it is not immediately clear to me how this can be implemented > without adding a disproportionate amount of overhead for something which I > would consider a rather minor feature. If an object only had a single > constructor this would be a simple flag, but if you want to allow one call > per each constructor in the hierarchy (i.e. you can call the constructor > and each parent constructor once), this information needs to be stored > somehow. The obvious way would be a hashset containing the constructors (or > CEs) that have been called on the object, but I don't think this would be > acceptable. > > Regards, > Nikita > Hey Nikic! Thanks for skimming over it. I also though about implementation already. My initial though was -- especially to keep it simple -- to simply delete the method from the object's table. Not sure if this is possible or just introduced more problems than it solves. Also considering that we think reflection should continue to allow calling it multiple times, though this is obviously still debatable. -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#97831) next »