Re: Unwrap reference after foreach

From: Date: Fri, 13 Aug 2021 14:04:25 +0000
Subject: Re: Unwrap reference after foreach
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115704@lists.php.net to get a copy of this message
-------- Original Message -------- On Aug 13, 2021, 9:28 AM, Nikita Popov < nikita.ppv@gmail.com> wrote: 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 This seems like a good opportunity to go one step further and have loops create a new scope, which would automagically handle the unwrapping with out worrying about the edge cases. Obviously, this would be a bigger BC break, but one worth considering. Trevor

« previous php.internals (#115704) next »