Re: [RFC][VOTE] Allow specifying keys in list()

From: Date: Fri, 12 Feb 2016 14:27:20 +0000
Subject: Re: [RFC][VOTE] Allow specifying keys in list()
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-91220@lists.php.net to get a copy of this message
S.A.N wrote on 12/02/2016 13:37:
Often all keys are unknown, or a very lot keys, use list(...) - is unreal. I would like to, instead <?php foreach($params as $key => $value) { $this{$key} = $value } Use the short syntax sugar <?php $this += $params ?> It's really do?
If the keys are unknown, then you probably don't want to blindly copy them onto object properties; at that point, you might as well just have $this->data and leave them as an array. It sounds like what you actually want is an object literal syntax - i.e. $params should never have been an array in the first place.

« previous php.internals (#91220) next »