From:             tony dot fraser at gmail dot com
Operating system: MAMP
PHP version:      5.3.0alpha2
PHP Bug Type:     SPL related
Bug description:  arrayObject count doesn't work correctly a specific instance.

Description:
------------
I have a class that extends ArrayObject. That class is a collection
(GenericCollection). Inside this GenericCollection, i have a little wrapper
class that wraps around whatever kind of classes I need to store in the
collection. 

In that GenericCollection, I have a method that goes into the objects in
the array object, searches a a text field in a certain way, is supposed to
return another instance of the class with a subset of the collection.
(like, all status=active collection objects in another genericcollection)

The problem is with that internal temporary instance of the collection,
tempGenericCollection->count doens't work.

Note, in main class of GenericCollection, count works fine, just not in
the temporary object that the GenericCollection creates.


Reproduce code:
---------------
The following is working code, but the comment says what doesn't work.
This code comes from within the GenericCollection class.

 $counter=0;
 while ($_iterator->valid()){
        $_tmp = $this->data->offSetGet($_iterator->key());

        $_thisObject =$_tmp->getObject();
        $_thisObjectID = $_tmp->getID();

        if ($_thisObject->getProperty($_field) == $_value){
          $_returnCollection->addObject($_thisObjectID, $_thisObject);
          $_counter++;
         }
        $_iterator->next();
  }
                
  //right here.. $_returnCollection->count() can't be used, always returns
zero.
  if ($_counter > 0)  {
  //error_log('returning an object with N items. N=' .
$_returnCollection->count());   
  return $_returnCollection;
}

Expected result:
----------------
I expect it to return the number of objects in the array. I have a print
method that shows everything, but even though the array is working
correctly, it isn't counting


Actual result:
--------------
0

-- 
Edit bug report at http://bugs.php.net/?id=46315&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46315&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46315&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46315&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46315&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46315&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46315&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46315&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46315&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46315&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46315&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46315&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46315&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46315&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46315&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46315&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46315&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46315&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46315&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46315&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46315&r=mysqlcfg

Reply via email to