> Le 13 août 2021 à 15:28, Nikita Popov <nikita....@gmail.com> a écrit :
> 
> Hi internals,
> 
> I'd like to address a common footgun when using foreach by reference:
> https://wiki.php.net/rfc/foreach_unwrap_ref
> 
> This addresses the issue described in the big red box at
> https://www.php.net/manual/en/control-structures.foreach.php. While this is
> "not a bug" (as our bug tracker can regularly attest), it's rather
> unexpected, and we could easily avoid it...
> 
> Regards,
> Nikita

A case that should be mentioned in the RFC is destructuring:

```php
foreach ($foo as [ $x, &$y ]) { /* .... */ }
```
https://3v4l.org/A5Vi7 <https://3v4l.org/A5Vi7>

I assume that the reference in `$y` would be unwrapped after the loop?

—Claude

Reply via email to