php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73207 Array ordering is same between 5.6.21 and 7.1.0 RC3
Submitted: 2016-09-30 08:40 UTC Modified: 2016-10-03 08:12 UTC
From: tuyen-truong at cybozu dot vn Assigned: cmb (profile)
Status: Closed Package: Arrays related
PHP Version: 7.1.0RC3 OS:
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: tuyen-truong at cybozu dot vn
New email:
PHP Version: OS:

 

 [2016-09-30 08:40 UTC] tuyen-truong at cybozu dot vn
Description:
------------
As description at
http://php.net/manual/en/migration70.incompatible.php
The "Array ordering when elements are automatically created during by reference assignments has changed" is written.
And there is no other description about array ordering in
http://php.net/manual/en/migration71.incompatible.php
But, when I have confirmed the result, I saw that the output of php5.6.21 and php7.1.0RC3 are same.

I think that it is bug of PHP7.1.0RC3, but please confirm it is a bug or not.
Thank you.



Test script:
---------------
1.
php56.exe -r "$array = []; $array['a'] =& $array['b']; $array['b'] = 1; var_dump($array);"
Output:
array(2) {
  ["b"]=>
  &int(1)
  ["a"]=>
  &int(1)
}

2. // php7.0.6
php70.exe -r "$array = []; $array['a'] =& $array['b']; $array['b'] = 1; var_dump($array);"
Output:
array(2) {
  ["a"]=>
  &int(1)
  ["b"]=>
  &int(1)
}

3.
php71.exe -r "$array = []; $array['a'] =& $array['b']; $array['b'] = 1; var_dump($array);"
Output:
array(2) {
  ["b"]=>
  &int(1)
  ["a"]=>
  &int(1)
}



Expected result:
----------------
When executing this script
3.
php71.exe -r "$array = []; $array['a'] =& $array['b']; $array['b'] = 1; var_dump($array);"

The output will be same the output of php7.0.6
array(2) {
  ["a"]=>
  &int(1)
  ["b"]=>
  &int(1)
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-30 09:33 UTC] yohgaki@php.net
Behavior changed between 7.1.0 alpha3 and 7.1.0 beta1.
https://3v4l.org/TiMHY
 [2016-09-30 09:57 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-09-30 09:57 UTC] cmb@php.net
Indeed, the behavior changed again as of PHP 7.1.0beta1, see
<https://3v4l.org/BPNL3>. Not sure if that is a bug or rather a
documentation issue.
 [2016-09-30 10:41 UTC] nikic@php.net
-Type: Bug +Type: Documentation Problem
 [2016-09-30 10:41 UTC] nikic@php.net
The change is intentional. We found that we cannot support the evaluation order in PHP 7.0 in a way that is memory-safe in certain edge-cases, so we had to go back to the previous ordering. (However, evaluation of side-effects will still occur in left-to-right order.)
 [2016-09-30 10:48 UTC] cmb@php.net
-Status: Verified +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2016-09-30 10:48 UTC] cmb@php.net
Okay; I think that a respective note in UPGRADING is appropriate.
FTR: see bug #71539.
 [2016-10-03 04:37 UTC] tuyen-truong at cybozu dot vn
I see that related bug has been reopened(bug #71539).
You mean that after this bug is fixed, the array order will be same as php 5.6 series, is that right?
 [2016-10-03 08:12 UTC] cmb@php.net
> You mean that after this bug is fixed, the array order will be
> same as php 5.6 series, is that right?

Unfortunately, #71539 can't be fixed for BC reasons, so PHP 7.0
will keep the other ordering.
 [2016-10-03 16:57 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5b52d5acde35d01b774a459b3978a9c5da2c64ab
Log: Fix #73207: Array ordering is same between 5.6.21 and 7.1.0 RC3
 [2016-10-03 16:57 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2016-10-03 17:25 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=340288
Log: Fix #73207: Array ordering is same between 5.6.21 and 7.1.0 RC3
 [2016-10-17 10:07 UTC] bwoebi@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5b52d5acde35d01b774a459b3978a9c5da2c64ab
Log: Fix #73207: Array ordering is same between 5.6.21 and 7.1.0 RC3
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b953523528f6429bea86ec1f81480ecdd279b7c7
Log: Fix #73207: Array ordering is same between 5.6.21 and 7.1.0 RC3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC