ID: 44485
Updated by: [EMAIL PROTECTED]
Reported By: computerlov at yahoo dot com
-Status: Open
+Status: Feedback
Bug Type: Class/Object related
Operating System: windows xp
PHP Version: 5.2.5
New Comment:
Please, send the complete example. I can't reproduce.
<?php
class CSomeClass {
private $m_var1;
private $m_var2;
}
$oSomeClass = new CSomeClass();
$arrObjects = array();
for ($i = 0; $i < 10; $i++) {
$arrObjects[] = new stdClass;
}
var_dump(array_splice($arrObjects, 8, 2, $oSomeClass));
/* Output:
array(2) {
[0]=>
object(stdClass)#10 (0) {
}
[1]=>
object(stdClass)#11 (0) {
}
}
*/
Previous Comments:
------------------------------------------------------------------------
[2008-03-19 20:58:43] computerlov at yahoo dot com
Description:
------------
when doing something like this:
$arrOfObjects = array($obj1, obj2....obj10);
$oSomeObject = new CSomeClass();
array_splice($arrOfObjects, 8, 2, $oSomeObject);
instead of getting an array of 9 objects, you get an array of 8 objects
and all the data members of CSomeClass in the array.
it's as if we kind of 'var_dumped' the object into the array instead
of copying it to the array.
Reproduce code:
---------------
class CSomeClass
{
private $m_var1;
private $m_var2;
}
...
$oSomeClass = new CSomeClass();
.. Do Stuff on $oSomeClass ..
$arrObjects = ($obj1, $obj2);
array_splice($arrObjects, 1, 1, $oSomeClass);
Expected result:
----------------
$arrObjects = {$obj1, $obj2, $oSomeClass}
Actual result:
--------------
$arrObjects = {$obj1, $obj2, $m_var1, $m_var2}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44485&edit=1