ID: 49279
Updated by: [email protected]
Reported By: andrew at ajohnstone dot com
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: debain
PHP Version: 5.2.10
New Comment:
None of the array functions work with iterator interface, its designed
to allow you iterate through objects with foreach() / while().
Previous Comments:
------------------------------------------------------------------------
[2009-08-17 13:45:24] andrew at ajohnstone dot com
Description:
------------
Current does not seem to work with Iterator
Reproduce code:
---------------
<?php
class test implements IteratorAggregate, Iterator {
protected $_data = array(
0=>1,
1=>2,
2=>3,
3=>4,
4=>5,
);
public function getIterator() {
var_dump(__FUNCTION__);
return $this->getCurrentItems();
}
public function getCurrentItems() {
return $this->_data;
}
public function current() {
var_dump(__FUNCTION__);
$this->_data = $this->getCurrentItems();
return current($this->_data);
}
public function key() {
var_dump(__FUNCTION__);
return key($this->_data);
}
public function next() {
var_dump(__FUNCTION__);
next($this->_data);
}
public function rewind() {
var_dump(__FUNCTION__);
$this->_data = $this->getCurrentItems();
$this->_pointer = 0;
reset($this->_data);
}
public function valid() {
var_dump(__FUNCTION__);
return (current($this->_data) !== FALSE);
}
}
$c = new test();
var_dump(current($c));
Expected result:
----------------
string 'current' (length=7)
1
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49279&edit=1