diff --git a/hphp/system/php.txt b/hphp/system/php.txt index eacc84b11..849fd5d62 100644 --- a/hphp/system/php.txt +++ b/hphp/system/php.txt @@ -65,6 +65,9 @@ hphp/system/php/spl/datastructures/SplObjectStorage.php hphp/system/php/spl/datastructures/SplPriorityQueue.php hphp/system/php/spl/iterators/AppendIterator.php hphp/system/php/spl/iterators/ArrayIterator.php +hphp/system/php/spl/iterators/EmptyIterator.php +hphp/system/php/spl/iterators/InfiniteIterator.php hphp/system/php/spl/iterators/LimitIterator.php +hphp/system/php/spl/iterators/NoRewindIterator.php hphp/system/php/spl/iterators/RecursiveIteratorIterator.php hphp/system/php/spl/miscellaneous/ArrayObject.php diff --git a/hphp/system/php/spl/iterators/EmptyIterator.php b/hphp/system/php/spl/iterators/EmptyIterator.php new file mode 100644 index 000000000..11310e14a --- /dev/null +++ b/hphp/system/php/spl/iterators/EmptyIterator.php @@ -0,0 +1,77 @@ +getInnerIterator(); + $this->_setPosition(0); + $iter->rewind(); + $this->valid = $this->_fetch(true); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/infiniteiterator.next.php ) + * + * Moves the inner Iterator forward to its next element if there is one, + * otherwise rewinds the inner Iterator back to the beginning. + * + * Even an InfiniteIterator stops if its inner Iterator is empty. + * + * @return mixed No value is returned. + */ + public function next() { + $iter = $this->getInnerIterator(); + $this->_setPosition($this->_getPosition() + 1); + $iter->next(); + if ($iter->valid()) { + $this->valid = $this->_fetch(false); + } else { + $this->_setPosition(0); + $iter->rewind(); + if ($iter->valid()) { + $this->valid = $this->_fetch(false); + } + } + } + + public function valid() { + return $this->valid; + } + +} + diff --git a/hphp/system/php/spl/iterators/IteratorIterator.php b/hphp/system/php/spl/iterators/IteratorIterator.php index 1457aeee0..f0e8581b0 100644 --- a/hphp/system/php/spl/iterators/IteratorIterator.php +++ b/hphp/system/php/spl/iterators/IteratorIterator.php @@ -15,7 +15,6 @@ class IteratorIterator implements OuterIterator { private $iterator; private $current; private $key; - private $valid; private $position; // This doc comment block generated by idl/sysdoc.php @@ -101,7 +100,7 @@ class IteratorIterator implements OuterIterator { */ public function next() { $this->iterator->next(); - $this->_position++; + $this->position++; $this->_fetch(true); return; } @@ -116,7 +115,7 @@ class IteratorIterator implements OuterIterator { */ public function rewind() { $this->iterator->rewind(); - $this->_position = 0; + $this->position = 0; $this->_fetch(true); return; } @@ -139,7 +138,7 @@ class IteratorIterator implements OuterIterator { if (!$check || $this->iterator->valid()) { $this->current = $this->iterator->current(); $key = $this->iterator->key(); - $this->key = is_null($key) ? $this->_position : $key; + $this->key = is_null($key) ? $this->position : $key; return true; } return false; diff --git a/hphp/system/php/spl/iterators/NoRewindIterator.php b/hphp/system/php/spl/iterators/NoRewindIterator.php new file mode 100644 index 000000000..4c0d0026c --- /dev/null +++ b/hphp/system/php/spl/iterators/NoRewindIterator.php @@ -0,0 +1,87 @@ +needsRefresh = true; + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/norewinditerator.current.php ) + * + * Gets the current value. Warning: This function is currently not + * documented; only its argument list is available. + * + * @return mixed The current value. + */ + public function current() { + if ($this->needsRefresh) { + $this->current = $this->getInnerIterator()->current(); + } + $this->needsRefresh = false; + return $this->current; + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/norewinditerator.key.php ) + * + * Gets the current key. Warning: This function is currently not + * documented; only its argument list is available. + * + * @return mixed The current key. + */ + public function key() { + return $this->getInnerIterator()->key(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/norewinditerator.rewind.php ) + * + * Prevents the rewind operation on the inner iterator. + * + * @return mixed No value is returned. + */ + public function rewind() { + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/norewinditerator.next.php ) + * + * Forwards to the next element. Warning: This function is currently not + * documented; only its argument list is available. + * + * @return mixed No value is returned. + */ + public function next() { + $this->getInnerIterator()->next(); + $this->needsRefresh = true; + } + +} diff --git a/hphp/test/zend/bad/ext-spl/iterator_007.php b/hphp/test/zend/good/ext-spl/iterator_007.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_007.php rename to hphp/test/zend/good/ext-spl/iterator_007.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_007.php.expectf b/hphp/test/zend/good/ext-spl/iterator_007.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_007.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_007.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_008.php b/hphp/test/zend/good/ext-spl/iterator_008.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_008.php rename to hphp/test/zend/good/ext-spl/iterator_008.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_008.php.expectf b/hphp/test/zend/good/ext-spl/iterator_008.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_008.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_008.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_009.php b/hphp/test/zend/good/ext-spl/iterator_009.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_009.php rename to hphp/test/zend/good/ext-spl/iterator_009.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_009.php.expectf b/hphp/test/zend/good/ext-spl/iterator_009.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_009.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_009.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_010.php b/hphp/test/zend/good/ext-spl/iterator_010.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_010.php rename to hphp/test/zend/good/ext-spl/iterator_010.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_010.php.expectf b/hphp/test/zend/good/ext-spl/iterator_010.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_010.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_010.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_011.php b/hphp/test/zend/good/ext-spl/iterator_011.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_011.php rename to hphp/test/zend/good/ext-spl/iterator_011.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_011.php.expectf b/hphp/test/zend/good/ext-spl/iterator_011.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_011.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_011.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_012.php b/hphp/test/zend/good/ext-spl/iterator_012.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_012.php rename to hphp/test/zend/good/ext-spl/iterator_012.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_012.php.expectf b/hphp/test/zend/good/ext-spl/iterator_012.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_012.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_012.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_013.php b/hphp/test/zend/good/ext-spl/iterator_013.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_013.php rename to hphp/test/zend/good/ext-spl/iterator_013.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_013.php.expectf b/hphp/test/zend/good/ext-spl/iterator_013.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_013.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_013.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_017.php b/hphp/test/zend/good/ext-spl/iterator_017.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_017.php rename to hphp/test/zend/good/ext-spl/iterator_017.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_017.php.expectf b/hphp/test/zend/good/ext-spl/iterator_017.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_017.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_017.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_018.php b/hphp/test/zend/good/ext-spl/iterator_018.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_018.php rename to hphp/test/zend/good/ext-spl/iterator_018.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_018.php.expectf b/hphp/test/zend/good/ext-spl/iterator_018.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_018.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_018.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_019.php b/hphp/test/zend/good/ext-spl/iterator_019.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_019.php rename to hphp/test/zend/good/ext-spl/iterator_019.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_019.php.expectf b/hphp/test/zend/good/ext-spl/iterator_019.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_019.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_019.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_020.php b/hphp/test/zend/good/ext-spl/iterator_020.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_020.php rename to hphp/test/zend/good/ext-spl/iterator_020.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_020.php.expectf b/hphp/test/zend/good/ext-spl/iterator_020.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_020.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_020.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_030.php b/hphp/test/zend/good/ext-spl/iterator_030.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_030.php rename to hphp/test/zend/good/ext-spl/iterator_030.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_030.php.expectf b/hphp/test/zend/good/ext-spl/iterator_030.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_030.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_030.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_038.php b/hphp/test/zend/good/ext-spl/iterator_038.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_038.php rename to hphp/test/zend/good/ext-spl/iterator_038.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_038.php.expectf b/hphp/test/zend/good/ext-spl/iterator_038.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_038.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_038.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/iterator_039.php b/hphp/test/zend/good/ext-spl/iterator_039.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_039.php rename to hphp/test/zend/good/ext-spl/iterator_039.php diff --git a/hphp/test/zend/bad/ext-spl/iterator_039.php.expectf b/hphp/test/zend/good/ext-spl/iterator_039.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/iterator_039.php.expectf rename to hphp/test/zend/good/ext-spl/iterator_039.php.expectf