Bug #72108 [Opn->Dup]: switchs break foreach byref with arrays
| From: | requinix@php.net | Date: | Tue, 26 Apr 2016 19:20:37 +0000 |
| Subject: | Bug #72108 [Opn->Dup]: switchs break foreach byref with arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200788@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72108&edit=1
ID: 72108
Updated by: requinix@php.net
Reported by: php at darkain dot com
Summary: switchs break foreach byref with arrays
-Status: Open
+Status: Duplicate
Type: Bug
Package: Scripting Engine problem
Operating System: Debian 8.2
PHP Version: 7.0.5
Block user comment: N
Private report: N
New Comment:
Yet another duplicate of bug #71914.
Previous Comments:
------------------------------------------------------------------------
[2016-04-26 17:56:03] php at darkain dot com
Description:
------------
As shown in the test script, when a switch statement is used on a byref variable from a foreach, the
reference is lost, and it changes to byval instead.
This regression was introduced in 7.0.5, and worked perfectly otherwise in previous builds of 7.0.x,
5.6, and HHVM
https://3v4l.org/eg1oT
Test script:
---------------
$array = ['broken'];
foreach($array as &$values) {
switch ($values) {
case 'broken':
$values = 'WORKING';
break;
}
}
var_dump($array);
Expected result:
----------------
array(1) {
[0]=>
&string(7) "WORKING"
}
Actual result:
--------------
array(1) {
[0]=>
string(6) "broken"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72108&edit=1