|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72108 switchs break foreach byref with arrays
Submitted: 2016-04-26 17:56 UTC Modified: 2016-04-26 19:20 UTC
From: php at darkain dot com Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.0.5 OS: Debian 8.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php at darkain dot com
New email:
PHP Version: OS:


 [2016-04-26 17:56 UTC] php at darkain dot com
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

Test script:
$array = ['broken'];

foreach($array as &$values) {
	switch ($values) {
		case 'broken':
			$values = 'WORKING';


Expected result:
array(1) {
  &string(7) "WORKING"

Actual result:
array(1) {
  string(6) "broken"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-26 17:57 UTC]
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2016-04-26 19:20 UTC]
-Status: Open +Status: Duplicate
 [2016-04-26 19:20 UTC]
Yet another duplicate of bug #71914.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 04:01:28 2024 UTC