Skip to content

Commit

Permalink
- Synch naming/move changes with HEAD
Browse files Browse the repository at this point in the history
- Update tests/docu
# New functionality in CachingIterator/RecursiveIteratorIterator not MFHed
  • Loading branch information
helly25 committed Sep 18, 2005
1 parent 7e76298 commit 7d918fa
Show file tree
Hide file tree
Showing 19 changed files with 315 additions and 272 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ PHP NEWS
classes. (Dmitry, Michael Wallner)
- Added "new_link" parameter to mssql_connect(). Bug #34369. (Frank)
- Improved SPL extension. (Marcus)
. Added RecursiveFilterIterator
. Moved RecursiveArrayIterator from examples into extension
. Moved RecursiveFilterIterator from examples into extension
. Added SplObjectStorage
. Made all SPL constants class constants
. Renamed CachingRecursiveIterator to RecursiveCachingIteraotr to follow
Recursive<*>Iterator naming scheme.
- Upgraded bundled SQLite library for PDO:SQLite to 3.2.5 (Ilia)
- Upgraded SQLite 2 library in ext/sqlite to 2.8.16 (Ilia)
- Upgraded PCRE library to version 6.2. (Andrei)
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/examples/directorygraphiterator.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DirectoryGraphIterator extends DirectoryTreeIterator
{
function __construct($path)
{
RecursiveIteratorIterator::__construct(new CachingRecursiveIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
RecursiveIteratorIterator::__construct(new RecursiveCachingIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/examples/directorytreeiterator.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DirectoryTreeIterator extends RecursiveIteratorIterator
*/
function __construct($path)
{
parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
parent::__construct(new RecursiveCachingIterator(new RecursiveDirectoryIterator($path), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
}

/** @return the current element prefixed with ASCII graphics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* SPL - Standard PHP Library
*/

/** @ingroup Examples
/** @ingroup SPL
* @brief A recursive array iterator
* @author Marcus Boerger
* @version 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/** @file cachingrecursiveiterator.inc
/** @file recursivecachingiterator.inc
* @ingroup SPL
* @brief class CachingRecursiveIterator
* @brief class RecursiveCachingIterator
* @author Marcus Boerger
* @date 2003 - 2005
*
Expand All @@ -12,12 +12,12 @@
/**
* @brief Cached recursive iteration over another Iterator
* @author Marcus Boerger
* @version 1.1
* @since PHP 5.0
* @version 1.2
* @since PHP 5.1
*
* @see CachingIterator
*/
class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
{
private $hasChildren;
private $getChildren;
Expand Down Expand Up @@ -48,25 +48,34 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera
*/
function next()
{
if ($this->hasChildren = $this->it->hasChildren()) {
try {
//$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->flags);
// workaround memleaks...
if ($this->hasChildren = $this->it->hasChildren())
{
try
{
$child = $this->it->getChildren();
$this->getChildren = new CachingRecursiveIterator($child, $this->flags);
if (!$this->ref)
{
$this->ref = new ReflectionClass($this);
}
$this->getChildren = $ref->newInstance($child, $this->flags);
}
catch(Exception $e) {
if (!$this->flags & self::CATCH_GET_CHILD) {
catch(Exception $e)
{
if (!$this->flags & self::CATCH_GET_CHILD)
{
throw $e;
}
$this->hasChildren = false;
$this->getChildren = NULL;
}
} else {
} else
{
$this->getChildren = NULL;
}
parent::next();
}

private $ref;

/** @return whether the current element has children
* @note The check whether the Iterator for the children can be created was
Expand Down
3 changes: 2 additions & 1 deletion ext/spl/php_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ PHP_FUNCTION(class_implements)
SPL_ADD_CLASS(BadFunctionCallException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(BadMethodCallException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(CachingIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(CachingRecursiveIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
Expand All @@ -175,6 +174,8 @@ PHP_FUNCTION(class_implements)
SPL_ADD_CLASS(OverflowException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(ParentIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RangeException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveArrayIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveCachingIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveDirectoryIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveFilterIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RecursiveIterator, z_list, sub, allow, ce_flags); \
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* - interface SeekableIterator implements Iterator
* - class LimitIterator implements OuterIterator
* - class CachingIterator implements OuterIterator
* - class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
* - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
* - class IteratorIterator implements OuterIterator
* - class NoRewindIterator implements OuterIterator
* - class EmptyIterator implements Iterator
Expand Down
Loading

0 comments on commit 7d918fa

Please sign in to comment.