From: andrew at ajohnstone dot com
Operating system: debain
PHP version: 5.2.10
PHP Bug Type: *General Issues
Bug description: Current does not seem to work with Iterator
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 bug report at http://bugs.php.net/?id=49279&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49279&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49279&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49279&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49279&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49279&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49279&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49279&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49279&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49279&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49279&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49279&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49279&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49279&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49279&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49279&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49279&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49279&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49279&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49279&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49279&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49279&r=mysqlcfg