|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-08-17 14:02 UTC] scottmac@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 06:00:01 2025 UTC |
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)