From:             adam at trachtenberg dot com
Operating system: Mac OS X 10.3
PHP version:      5CVS-2003-11-12 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  getIterator() doesn't work with arrays.

Description:
------------
Having getIterator() return an array instead of an 
object that implements Iterator causes a bus error / seg 
fault.

The ZE2 Changes document says "method 
getIterator() which must return an array or an object 
that either implements the interface Iterator...."

Trying to return non-array values (which should not be 
allowed), like 'foo', also cause crashes instead of 
returning an error.

Reproduce code:
---------------
class array_iterator implements IteratorAggregate {
        public function getIterator() {
                return array('foo', 'bar');     
        }
}

$obj = new array_iterator;
foreach ($obj as $property => $value) {
        print "$value\n";
}

Expected result:
----------------
foo
bar

Actual result:
--------------
Bus Error

-- 
Edit bug report at http://bugs.php.net/?id=26229&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26229&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26229&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26229&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26229&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26229&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26229&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26229&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26229&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26229&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26229&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26229&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26229&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26229&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26229&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26229&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26229&r=float

Reply via email to