From 6e62230978712912daf294ff5ea18e3533330e13 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Wed, 12 Jun 2013 16:27:48 -0700 Subject: [PATCH] RecursiveFilterIterator simple --- bin/systemlib.php | 318 +++++++++++------- hphp/system/classes.txt | 3 +- .../spl/iterators/RecursiveFilterIterator.php | 61 ++++ 3 files changed, 252 insertions(+), 130 deletions(-) create mode 100644 hphp/system/classes/spl/iterators/RecursiveFilterIterator.php diff --git a/bin/systemlib.php b/bin/systemlib.php index f2f775324..c8bf1efac 100644 --- a/bin/systemlib.php +++ b/bin/systemlib.php @@ -2527,6 +2527,195 @@ class IteratorIterator implements OuterIterator { } } +// This doc comment block generated by idl/sysdoc.php +/** + * ( excerpt from http://php.net/manual/en/class.filteriterator.php ) + * + * This abstract iterator filters out unwanted values. This class should + * be extended to implement custom iterator filters. The + * FilterIterator::accept() must be implemented in the subclass. + * + */ +abstract class FilterIterator extends IteratorIterator { + private $it; + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.construct.php ) + * + * Constructs a new FilterIterator, which consists of a passed in iterator + * with filters applied to it. WarningThis function is currently not + * documented; only its argument list is available. + * + * @it mixed The iterator that is being filtered. + * + * @return mixed The FilterIterator. + */ + public function __construct(Iterator $it) { + $this->it = $it; + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.rewind.php ) + * + * + * @return mixed No value is returned. + */ + public function rewind() { + $this->it->rewind(); + $this->fetch(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.accept.php ) + * + * Returns whether the current element of the iterator is acceptable + * through this filter. + * + * @return mixed TRUE if the current element is acceptable, otherwise + * FALSE. + */ + abstract function accept(); + + private function fetch() { + while ($this->it->valid()) { + if ($this->accept()) { + return; + } + $this->it->next(); + } + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.next.php ) + * + * + * @return mixed No value is returned. + */ + public function next() { + $this->it->next(); + $this->fetch(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.valid.php ) + * + * + * @return mixed TRUE if the current element is valid, otherwise + * FALSE + */ + public function valid() { + return $this->it->valid(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.key.php ) + * + * + * @return mixed The current key. + */ + public function key() { + return $this->it->key(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from http://php.net/manual/en/filteriterator.current.php ) + * + * + * @return mixed The current element value. + */ + public function current() { + return $this->it->current(); + } + + protected function __clone() { + // disallow clone + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/filteriterator.getinneriterator.php ) + * + * + * @return mixed The inner iterator. + */ + public function getInnerIterator() { + return $this->it; + } + + public function __call($func, $params) { + return call_user_func_array(array($this->it, $func), $params); + } +} + + +// This doc comment block generated by idl/sysdoc.php +/** + * ( excerpt from + * http://php.net/manual/en/class.recursivefilteriterator.php ) + * + * This abstract iterator filters out unwanted values for a + * RecursiveIterator. This class should be extended to implement custom + * filters. The RecursiveFilterIterator::accept() must be implemented in + * the subclass. + * + */ +abstract class RecursiveFilterIterator extends FilterIterator + implements OuterIterator, RecursiveIterator { + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/recursivefilteriterator.construct.php ) + * + * Create a RecursiveFilterIterator from a RecursiveIterator. + * + * @iterator mixed The RecursiveIterator to be filtered. + * + * @return mixed No value is returned. + */ + public function __construct (RecursiveIterator $iterator) { + return parent::__construct($iterator); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/recursivefilteriterator.getchildren.php ) + * + * Return the inner iterator's children contained in a + * RecursiveFilterIterator. + * + * @return mixed Returns a RecursiveFilterIterator containing the + * inner iterator's children. + */ + public function getChildren() { + return $this->getInnerIterator()->getChildren(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/recursivefilteriterator.haschildren.php ) + * + * Check whether the inner iterator's current element has children. + * + * @return mixed TRUE if the inner iterator has children, otherwise + * FALSE + */ + public function hasChildren() { + return $this->getInnerIterator()->hasChildren(); + } + +} + interface DebuggerCommand { /** * Called when DebuggerClient needs to auto-complete. Inside this function, @@ -6872,135 +7061,6 @@ class ArrayIterator implements ArrayAccess, SeekableIterator, Countable { } -// This doc comment block generated by idl/sysdoc.php -/** - * ( excerpt from http://php.net/manual/en/class.filteriterator.php ) - * - * This abstract iterator filters out unwanted values. This class should - * be extended to implement custom iterator filters. The - * FilterIterator::accept() must be implemented in the subclass. - * - */ -abstract class FilterIterator extends IteratorIterator { - private $it; - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.construct.php ) - * - * Constructs a new FilterIterator, which consists of a passed in iterator - * with filters applied to it. WarningThis function is currently not - * documented; only its argument list is available. - * - * @it mixed The iterator that is being filtered. - * - * @return mixed The FilterIterator. - */ - public function __construct(Iterator $it) { - $this->it = $it; - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.rewind.php ) - * - * - * @return mixed No value is returned. - */ - public function rewind() { - $this->it->rewind(); - $this->fetch(); - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.accept.php ) - * - * Returns whether the current element of the iterator is acceptable - * through this filter. - * - * @return mixed TRUE if the current element is acceptable, otherwise - * FALSE. - */ - abstract function accept(); - - private function fetch() { - while ($this->it->valid()) { - if ($this->accept()) { - return; - } - $this->it->next(); - } - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.next.php ) - * - * - * @return mixed No value is returned. - */ - public function next() { - $this->it->next(); - $this->fetch(); - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.valid.php ) - * - * - * @return mixed TRUE if the current element is valid, otherwise - * FALSE - */ - public function valid() { - return $this->it->valid(); - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.key.php ) - * - * - * @return mixed The current key. - */ - public function key() { - return $this->it->key(); - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from http://php.net/manual/en/filteriterator.current.php ) - * - * - * @return mixed The current element value. - */ - public function current() { - return $this->it->current(); - } - - protected function __clone() { - // disallow clone - } - - // This doc comment block generated by idl/sysdoc.php - /** - * ( excerpt from - * http://php.net/manual/en/filteriterator.getinneriterator.php ) - * - * - * @return mixed The inner iterator. - */ - public function getInnerIterator() { - return $this->it; - } - - public function __call($func, $params) { - return call_user_func_array(array($this->it, $func), $params); - } -} - - // This doc comment block generated by idl/sysdoc.php /** * ( excerpt from diff --git a/hphp/system/classes.txt b/hphp/system/classes.txt index 5afc6d804..8e7bc85d9 100644 --- a/hphp/system/classes.txt +++ b/hphp/system/classes.txt @@ -22,6 +22,8 @@ hphp/system/classes/spl/file_handling/SplFileObject.php hphp/system/classes/spl/interfaces/OuterIterator.php hphp/system/classes/spl/iterators/IteratorIterator.php +hphp/system/classes/spl/iterators/FilterIterator.php +hphp/system/classes/spl/iterators/RecursiveFilterIterator.php # If you have no inheritance relationship, go here in alphabetical order hphp/system/classes/DebuggerCommand.php @@ -45,7 +47,6 @@ hphp/system/classes/spl/datastructures/SplObjectStorage.php hphp/system/classes/spl/datastructures/SplPriorityQueue.php hphp/system/classes/spl/iterators/AppendIterator.php hphp/system/classes/spl/iterators/ArrayIterator.php -hphp/system/classes/spl/iterators/FilterIterator.php hphp/system/classes/spl/iterators/RecursiveIteratorIterator.php hphp/system/classes/spl/miscellaneous/ArrayObject.php diff --git a/hphp/system/classes/spl/iterators/RecursiveFilterIterator.php b/hphp/system/classes/spl/iterators/RecursiveFilterIterator.php new file mode 100644 index 000000000..b6f07c411 --- /dev/null +++ b/hphp/system/classes/spl/iterators/RecursiveFilterIterator.php @@ -0,0 +1,61 @@ +getInnerIterator()->getChildren(); + } + + // This doc comment block generated by idl/sysdoc.php + /** + * ( excerpt from + * http://php.net/manual/en/recursivefilteriterator.haschildren.php ) + * + * Check whether the inner iterator's current element has children. + * + * @return mixed TRUE if the inner iterator has children, otherwise + * FALSE + */ + public function hasChildren() { + return $this->getInnerIterator()->hasChildren(); + } + +}