php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70144 Assigning value to uninitialized byref array keys changed array order with PHP 7
Submitted: 2015-07-27 00:23 UTC Modified: 2015-07-27 10:01 UTC
From: admin at angosso dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.0beta2 OS: Linux, Windows, Mac
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: admin at angosso dot net
New email:
PHP Version: OS:

 

 [2015-07-27 00:23 UTC] admin at angosso dot net
Description:
------------
 The Elements of the code or object properties will be created automatically for the server [dot] in reference and assignment for bug.

Test script:
---------------
$array = [];
      $array["a"] =& $array["b"];
      $array["b"] = 1;
      var_dump($array);

  now results in the array ["a" => 1, "b" => 1], while previously the result
  was ["b" => 1, "a" => 1];

Expected result:
----------------
/rfc/uniform_variable_syntax
/rfc/abstract_syntax_tree
Stack trace:
      #0 file.php(4): foo(42)
      #1 {main}


Patches

add (last revision 2015-07-27 00:29 UTC by admin at angosso dot net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-27 01:05 UTC] requinix@php.net
-Summary: src_server +Summary: Assigning value to uninitialized byref array keys changed array order with PHP 7 -Status: Open +Status: Verified -Package: Built-in web server +Package: Scripting Engine problem -PHP Version: 5.6.11 +PHP Version: 7.0.0
 [2015-07-27 01:37 UTC] requinix@php.net
-PHP Version: 7.0.0 +PHP Version: 7.0.0beta2
 [2015-07-27 03:12 UTC] laruence@php.net
this is a side affects by the new AST based compiler.

previously, we fetch_dim_w b first, then fetch_dim_w a

but now we always evaluate the expr from left to right.

so, basically, I don't think here is something need to be fixed.
 [2015-07-27 10:01 UTC] nikic@php.net
-Status: Verified +Status: Not a bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC