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

From: Date: Fri, 12 Feb 2016 14:39:45 +0000
Subject: Re: [RFC][VOTE] Allow specifying keys in list()
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-91221@lists.php.net to get a copy of this message
2016-02-12 16:27 GMT+02:00 Rowan Collins <rowan.collins@gmail.com>: > 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. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > I would operator (+=) as like to function Object.assign() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

« previous php.internals (#91221) next »