Re: [PHP-DEV] array coalesce operator concept

2017-07-12 Thread Mark Shust
Stas, Wow, for some reason it didn't occur to me to try that. Confirming the following works: foreach ($foo ?? [] as $bar) { echo $bar; } I think the biggest need for this is if the value is null. Guess it's case-closed :) Might be a good idea to add this to the docs, pretty neat. Mark

Re: [PHP-DEV] array coalesce operator concept

2017-07-12 Thread Mark Shust
ything failing in the entire loop block. > > If we're going to introduce this behaviour, let's get it right ;-) (even > if we don't like it ourselves) > > Kind regards, > Aidan > > On 12 July 2017 at 16:26, MichaƂ Brzuchalski > wrote: > >> 12.07.2017

Re: [PHP-DEV] array coalesce operator concept

2017-07-12 Thread Mark Shust
> Kind regards, > Aidan > > On 12 July 2017 at 02:50, Mark Shust wrote: > >> Aidan, >> >> Fantastic suggestion (@as) -- that is really the succinctness I was >> initially looking for, and I think the intention makes a lot of sense. My >> only concern/is

Re: [PHP-DEV] array coalesce operator concept

2017-07-11 Thread Mark Shust
prevent skip past execution of the entire foreach block if there is > an error using $foo as an array. So might make most sense to place the `@` > on `as`, IMO, but I guess arguments could be made to place it like > `@foreach ($foo as $bar)` or `foreach @($foo as $bar)`. > > > Re

Re: [PHP-DEV] array coalesce operator concept

2017-07-11 Thread Mark Shust
Collins wrote: > On 11 July 2017 16:02:18 BST, Mark Shust wrote: > >For a syntactic > >sugar/improvement, this can be shorthand for executing the loop instead > >of > >wrapping the block within an is_array check: > > > > > > > > >$foo = "a

[PHP-DEV] array coalesce operator concept

2017-07-11 Thread Mark Shust
Hello, I wanted to garnish feedback on a RFC proposal. This is just a concept at this point, and is inspired by the null coalesce operator. Code will error if a non-array value is passed through a looping feature. For example, this code: