Bug #61326 [Asn->Csd]: ArrayObject comparison
| From: | cataphract@php.net | Date: | Sat, 10 Mar 2012 17:19:43 +0000 |
| Subject: | Bug #61326 [Asn->Csd]: ArrayObject comparison | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-168337@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61326&edit=1
ID: 61326
Updated by: cataphract@php.net
Reported by: aim at secoya dot dk
Summary: ArrayObject comparison
-Status: Assigned
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Windows 7 x64
PHP Version: 5.3.10
Assigned To: cataphract
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2012-03-10 17:19:29] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=324082
Log: - Fixed bug #61326 (ArrayObject comparison).
------------------------------------------------------------------------
[2012-03-08 15:23:57] aim at secoya dot dk
Description:
------------
When constructing ArrayObjects by passing arrays to their constructor subsequent
object comparisons do not return the right result.
Only by using getArrayCopy, we get the proper result.
Test script:
---------------
<?php
$a = array();
$b = array();
$a[] = 0;
$b[] = 0;
echo '$a==$b .. ';
var_dump($a==$b);
$b[] = 1;
echo '$b[] = 1; $a==$b .. ';
var_dump($a==$b);
$a_o = new ModifiedArrayObject($a);
$b_o = new ModifiedArrayObject($b);
echo '$a_o==$b_o .. ';
var_dump($a_o==$b_o);
echo '$a_o->compareTo($b_o) .. ';
var_dump($a_o->compareTo($b_o));
class ModifiedArrayObject extends ArrayObject {
public function compareTo(ArrayObject $a) {
$to = $a->getArrayCopy();
return $this->getArrayCopy() == $to;
}
}
Expected result:
----------------
$a_o == $b_o returns false.
Actual result:
--------------
$a_o == $b_o returns true.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61326&edit=1