|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-03-09 02:27 UTC] aharvey@php.net
-Package: SPL_Types
+Package: SPL related
[2012-03-10 15:40 UTC] cataphract@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: cataphract
[2012-03-10 17:19 UTC] cataphract@php.net
[2012-03-10 17:19 UTC] cataphract@php.net
-Status: Assigned
+Status: Closed
[2012-03-10 17:19 UTC] cataphract@php.net
[2012-04-18 09:45 UTC] laruence@php.net
[2012-07-24 23:36 UTC] rasmus@php.net
[2013-11-17 09:33 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 10:00:01 2025 UTC |
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.