ID:               37836
 Updated by:       [EMAIL PROTECTED]
 Reported By:      freebsd at akruijff dot dds dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: FreeBSD 6.1
 PHP Version:      5.1.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.


Previous Comments:
------------------------------------------------------------------------

[2006-06-18 06:44:56] freebsd at akruijff dot dds dot nl

Description:
------------
The same objects ends up being added multiple times to the internal
array. I don't understand why this happens.

Reproduce code:
---------------
class X {
  private $arr = array();

  function add(X &$y) {
    $this->arr[] =& $y;
  }
}
  
$x = new X();
for ($i = 0; $i < 10; $i++) {
  $y = new X();
  echo "$i: adding $y to $x<br>";
  $x->add($y);
}


Expected result:
----------------
I'm expecting to see this:
0: adding Object id #2 to Object id #1
1: adding Object id #3 to Object id #1
2: adding Object id #4 to Object id #1
3: adding Object id #5 to Object id #1
4: adding Object id #6 to Object id #1
5: adding Object id #7 to Object id #1
6: adding Object id #8 to Object id #1
7: adding Object id #9 to Object id #1
8: adding Object id #10 to Object id #1
9: adding Object id #11 to Object id #1


Actual result:
--------------
0: adding Object id #2 to Object id #1
1: adding Object id #3 to Object id #1
2: adding Object id #2 to Object id #1
3: adding Object id #3 to Object id #1
4: adding Object id #2 to Object id #1
5: adding Object id #3 to Object id #1
6: adding Object id #2 to Object id #1
7: adding Object id #3 to Object id #1
8: adding Object id #2 to Object id #1
9: adding Object id #3 to Object id #1


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37836&edit=1

Reply via email to