diff --git a/hphp/NEWS b/hphp/NEWS index 39a35ee25..2164f485a 100644 --- a/hphp/NEWS +++ b/hphp/NEWS @@ -1,5 +1,6 @@ "Tamale" 7/22/2013 + - Implement RecursiveArrayIterator - Optimize vector-shaped Arrays (arrays with keys in range 0..size-1) - Enable HHBC by default in debug builds - Implement SplObjectStorage::getInfo() diff --git a/hphp/system/php.txt b/hphp/system/php.txt index e035219e2..7f3a9a0bc 100644 --- a/hphp/system/php.txt +++ b/hphp/system/php.txt @@ -36,6 +36,9 @@ hphp/system/php/spl/iterators/IteratorIterator.php hphp/system/php/spl/iterators/FilterIterator.php hphp/system/php/spl/iterators/RecursiveFilterIterator.php +hphp/system/php/spl/iterators/ArrayIterator.php +hphp/system/php/spl/iterators/RecursiveArrayIterator.php + hphp/system/php/filter/filter_has_var.php hphp/system/php/filter/filter_input.php hphp/system/php/filter/filter_var_array.php @@ -67,7 +70,6 @@ hphp/system/php/spl/datastructures/SplFixedArray.php 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 diff --git a/hphp/system/php/spl/iterators/RecursiveArrayIterator.php b/hphp/system/php/spl/iterators/RecursiveArrayIterator.php new file mode 100644 index 000000000..61b1141a6 --- /dev/null +++ b/hphp/system/php/spl/iterators/RecursiveArrayIterator.php @@ -0,0 +1,54 @@ +hasChildren() ? $this->current() : null, + $this->getFlags() + ); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/recursivearrayiterator.haschildren.php ) + * + * Returns whether current entry is an array or an object for which an + * iterator can be obtained via RecursiveArrayIterator::getChildren(). + * + * @return mixed Returns TRUE if the current entry is an array or an + * object, otherwise FALSE is returned. + */ + public function hasChildren() { + return + is_array($this->current()) || + (is_object($this->current()) && + ($this->getFlags() & self::CHILD_ARRAYS_ONLY) == 0); + } + +} diff --git a/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php b/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php index 6a9807071..9df145d6b 100644 --- a/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php +++ b/hphp/system/php/spl/iterators/RecursiveIteratorIterator.php @@ -66,9 +66,9 @@ class RecursiveIteratorIterator implements OuterIterator, Traversable { */ public function getInnerIterator() { $it = $this->iterators[count($this->iterators)-1][0]; - if (!$it instanceof RecursiveDirectoryIterator) { + if (!$it instanceof RecursiveIterator) { throw new Exception( - "RecursiveIteratorIterator only supports RecursiveDirectoryIterator" + "inner iterator must implement RecursiveIterator" ); } return $it; @@ -200,7 +200,7 @@ class RecursiveIteratorIterator implements OuterIterator, Traversable { $it = $this->getInnerIterator(); if ($it->valid() && - $it->isDir() && + $it->hasChildren() && ($this->mode == self::LEAVES_ONLY || ($this->mode == self::CHILD_FIRST && $this->getInnerIteratorFlag() == 0))) { diff --git a/hphp/test/zend/good/ext-spl/bug54281.php b/hphp/test/zend/bad/ext-spl/bug54281.php similarity index 100% rename from hphp/test/zend/good/ext-spl/bug54281.php rename to hphp/test/zend/bad/ext-spl/bug54281.php diff --git a/hphp/test/zend/good/ext-spl/bug54281.php.expectf b/hphp/test/zend/bad/ext-spl/bug54281.php.expectf similarity index 100% rename from hphp/test/zend/good/ext-spl/bug54281.php.expectf rename to hphp/test/zend/bad/ext-spl/bug54281.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_009.php b/hphp/test/zend/good/ext-spl/array_009.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_009.php rename to hphp/test/zend/good/ext-spl/array_009.php diff --git a/hphp/test/zend/bad/ext-spl/array_009.php.expectf b/hphp/test/zend/good/ext-spl/array_009.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_009.php.expectf rename to hphp/test/zend/good/ext-spl/array_009.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/array_009a.php b/hphp/test/zend/good/ext-spl/array_009a.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_009a.php rename to hphp/test/zend/good/ext-spl/array_009a.php diff --git a/hphp/test/zend/bad/ext-spl/array_009a.php.expectf b/hphp/test/zend/good/ext-spl/array_009a.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/array_009a.php.expectf rename to hphp/test/zend/good/ext-spl/array_009a.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug31926.php b/hphp/test/zend/good/ext-spl/bug31926.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug31926.php rename to hphp/test/zend/good/ext-spl/bug31926.php diff --git a/hphp/test/zend/bad/ext-spl/bug31926.php.expectf b/hphp/test/zend/good/ext-spl/bug31926.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug31926.php.expectf rename to hphp/test/zend/good/ext-spl/bug31926.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug44615.php b/hphp/test/zend/good/ext-spl/bug44615.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug44615.php rename to hphp/test/zend/good/ext-spl/bug44615.php diff --git a/hphp/test/zend/bad/ext-spl/bug44615.php.expectf b/hphp/test/zend/good/ext-spl/bug44615.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug44615.php.expectf rename to hphp/test/zend/good/ext-spl/bug44615.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug46115.php b/hphp/test/zend/good/ext-spl/bug46115.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug46115.php rename to hphp/test/zend/good/ext-spl/bug46115.php diff --git a/hphp/test/zend/bad/ext-spl/bug46115.php.expectf b/hphp/test/zend/good/ext-spl/bug46115.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug46115.php.expectf rename to hphp/test/zend/good/ext-spl/bug46115.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/bug62262.php b/hphp/test/zend/good/ext-spl/bug62262.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug62262.php rename to hphp/test/zend/good/ext-spl/bug62262.php diff --git a/hphp/test/zend/bad/ext-spl/bug62262.php.expectf b/hphp/test/zend/good/ext-spl/bug62262.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/bug62262.php.expectf rename to hphp/test/zend/good/ext-spl/bug62262.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/spl_iterator_apply_error_001.php b/hphp/test/zend/good/ext-spl/spl_iterator_apply_error_001.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/spl_iterator_apply_error_001.php rename to hphp/test/zend/good/ext-spl/spl_iterator_apply_error_001.php diff --git a/hphp/test/zend/bad/ext-spl/spl_iterator_apply_error_001.php.expectf b/hphp/test/zend/good/ext-spl/spl_iterator_apply_error_001.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/spl_iterator_apply_error_001.php.expectf rename to hphp/test/zend/good/ext-spl/spl_iterator_apply_error_001.php.expectf diff --git a/hphp/test/zend/bad/ext-spl/spl_recursive_iterator_iterator_key_case.php b/hphp/test/zend/good/ext-spl/spl_recursive_iterator_iterator_key_case.php similarity index 100% rename from hphp/test/zend/bad/ext-spl/spl_recursive_iterator_iterator_key_case.php rename to hphp/test/zend/good/ext-spl/spl_recursive_iterator_iterator_key_case.php diff --git a/hphp/test/zend/bad/ext-spl/spl_recursive_iterator_iterator_key_case.php.expectf b/hphp/test/zend/good/ext-spl/spl_recursive_iterator_iterator_key_case.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-spl/spl_recursive_iterator_iterator_key_case.php.expectf rename to hphp/test/zend/good/ext-spl/spl_recursive_iterator_iterator_key_case.php.expectf diff --git a/hphp/test/zend/bad/zend/bug60138.php b/hphp/test/zend/good/zend/bug60138.php similarity index 100% rename from hphp/test/zend/bad/zend/bug60138.php rename to hphp/test/zend/good/zend/bug60138.php diff --git a/hphp/test/zend/bad/zend/bug60138.php.expectf b/hphp/test/zend/good/zend/bug60138.php.expectf similarity index 100% rename from hphp/test/zend/bad/zend/bug60138.php.expectf rename to hphp/test/zend/good/zend/bug60138.php.expectf