ID: 46315 Updated by: [EMAIL PROTECTED] Reported By: tony dot fraser at gmail dot com -Status: Open +Status: Feedback Bug Type: SPL related Operating System: MAMP PHP Version: 5.3.0alpha2 -Assigned To: +Assigned To: colder
Previous Comments: ------------------------------------------------------------------------ [2008-10-17 09:03:36] [EMAIL PROTECTED] So, $_returnCollection is a GenericCollection which extends ArrayObject, and $_returnCollection->count() doesn't work? Sounds like an userland mistake, could you please provide the code defining GenericCollection ? ------------------------------------------------------------------------ [2008-10-16 14:58:04] tony dot fraser at gmail dot com 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 this bug report at http://bugs.php.net/?id=46315&edit=1