Re: [PHP-DEV][RFC] Cast in foreach

2019-02-22 Thread Chris Riley
Cast would work for both key and value, although I think the instances where you need to cast a key will be fewer. On Thu, Feb 21, 2019, 15:08 Legale.legale wrote: > what about: > > foreach($array as $i=>$v) {} > > ?On Feb 21, 2019 13:15, Chris Riley wrote: > > > > Hi internals, > > > > I'd lik

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-22 Thread Chris Riley
In this instance, I would expect the cast to come before each variable eg foreach ($data as ["id" => (int) $id, "name" => (string) $name]) On Thu, Feb 21, 2019, 13:28 Kalle Sommer Nielsen wrote: > Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley : > > > > Hi internals, > > > > I'd like to prop

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Stanislav Malyshev
Hi! > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i=(int) $i; > } This doesn't seem to add anything to existing functionality - what's wrong with just maki

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Legale.legale
what about: foreach($array as $i=>$v) {} ?On Feb 21, 2019 13:15, Chris Riley wrote: > > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Riikka Kalliomäki
On Thu, Feb 21, 2019 at 3:36 PM Kalle Sommer Nielsen wrote: > > Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley : > > > > Hi internals, > > > > I'd like to propose opening an rfc to make the following syntax legal: > > > > foreach($array as (int) $i) {} > > How would this interact with the fore

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Kalle Sommer Nielsen
Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley : > > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} How would this interact with the foreach-list syntax? $data = [ ["id" => 1, "name" => 'Tom'], ["id" => 2, "n

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Marco Pivetta
On Thu, Feb 21, 2019 at 1:16 PM Chris Riley wrote: > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i=(int) $i; > } > > Thoughts? Feedback? > ~