php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72077 Passing reference variables breaks if that variable is used in a switch.
Submitted: 2016-04-22 14:33 UTC Modified: 2016-04-22 14:40 UTC
From: robertdesarbo at gmail dot com Assigned:
Status: Closed Package: Variables related
PHP Version: 7.0.5 OS: CentOS 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: robertdesarbo at gmail dot com
New email:
PHP Version: OS:

 

 [2016-04-22 14:33 UTC] robertdesarbo at gmail dot com
Description:
------------
If you pass a variable as a reference to a function and use that variable in a switch then the variable will not update outside the function.  This worked in 7.0.4 but is not working in 7.0.5.

Test script:
---------------
$var = 'WHAT_IS_THIS';
class BROKEN_VARIABLE_REF
{
    public function __construct() {}
    public function do_it( &$data )
    {
        switch($data) 
        {
            case 'WHAT_IS_THIS':
                $data = "I_WORK";
                break;
            default:
                $retFlag = false;
                break;
        }  
    }
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-22 14:40 UTC] robertdesarbo at gmail dot com
-Status: Open +Status: Closed
 [2016-04-22 14:40 UTC] robertdesarbo at gmail dot com
Ignore this, duplicate of https://bugs.php.net/bug.php?id=71948
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 22:01:35 2025 UTC