ID: 26229
User updated by: adam at trachtenberg dot com
-Summary: getIterator() doesn't work with arrays.
Reported By: adam at trachtenberg dot com
-Status: Closed
+Status: Open
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5.0.0b2
Assigned To: helly
New Comment:
It still shouldn't segfault when you return an array or
scalar.
Previous Comments:
------------------------------------------------------------------------
[2003-11-13 03:24:15] [EMAIL PROTECTED]
It is not possible to allow it to return arrays. If you really need to
mix objects with arrays you can use spl wich provides an array
iterator. Unfortunatley that part of spl doesn't work atm (i think).
But i will fix it during the next week.
------------------------------------------------------------------------
[2003-11-12 18:31:30] adam at trachtenberg dot com
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 this bug report at http://bugs.php.net/?id=26229&edit=1