mirror of
https://github.com/php/php-src.git
synced 2024-10-09 02:36:28 +00:00
a6feb3f405
- Update documentation - Move classes/interfaces already implemented in c to new subdir internal
53 lines
1.0 KiB
PHP
Executable File
53 lines
1.0 KiB
PHP
Executable File
<?php
|
|
|
|
class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
|
|
{
|
|
protected $hasChildren;
|
|
protected $getChildren;
|
|
|
|
function __construct(RecursiveIterator $it, $flags = CIT_CALL_TOSTRING)
|
|
{
|
|
parent::__construct($it, $flags);
|
|
}
|
|
|
|
function rewind();
|
|
{
|
|
$this->hasChildren = false;
|
|
$this->getChildren = NULL;
|
|
parent::rewind();
|
|
}
|
|
|
|
function next()
|
|
{
|
|
if ($this->hasChildren = $this->it->hasChildren()) {
|
|
try {
|
|
//$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->flags);
|
|
// workaround memleaks...
|
|
$child = $this->it->getChildren();
|
|
$this->getChildren = new CachingRecursiveIterator($child, $this->flags);
|
|
}
|
|
catch(Exception $e) {
|
|
if (!$this->flags & CIT_CATCH_GET_CHILD) {
|
|
throw $e;
|
|
}
|
|
$this->hasChildren = false;
|
|
$this->getChildren = NULL;
|
|
}
|
|
} else {
|
|
$this->getChildren = NULL;
|
|
}
|
|
parent::next();
|
|
}
|
|
|
|
function hasChildren()
|
|
{
|
|
return $this->hasChildren;
|
|
}
|
|
|
|
function getChildren()
|
|
{
|
|
return $this->getChildren;
|
|
}
|
|
}
|
|
|
|
?>
|