Skip to content

Commit 7d918fa

Browse files
committed
- Synch naming/move changes with HEAD
- Update tests/docu # New functionality in CachingIterator/RecursiveIteratorIterator not MFHed
1 parent 7e76298 commit 7d918fa

19 files changed

+315
-272
lines changed

NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ PHP NEWS
77
classes. (Dmitry, Michael Wallner)
88
- Added "new_link" parameter to mssql_connect(). Bug #34369. (Frank)
99
- Improved SPL extension. (Marcus)
10-
. Added RecursiveFilterIterator
10+
. Moved RecursiveArrayIterator from examples into extension
11+
. Moved RecursiveFilterIterator from examples into extension
1112
. Added SplObjectStorage
1213
. Made all SPL constants class constants
14+
. Renamed CachingRecursiveIterator to RecursiveCachingIteraotr to follow
15+
Recursive<*>Iterator naming scheme.
1316
- Upgraded bundled SQLite library for PDO:SQLite to 3.2.5 (Ilia)
1417
- Upgraded SQLite 2 library in ext/sqlite to 2.8.16 (Ilia)
1518
- Upgraded PCRE library to version 6.2. (Andrei)

ext/spl/examples/directorygraphiterator.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DirectoryGraphIterator extends DirectoryTreeIterator
1818
{
1919
function __construct($path)
2020
{
21-
RecursiveIteratorIterator::__construct(new CachingRecursiveIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
21+
RecursiveIteratorIterator::__construct(new RecursiveCachingIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
2222
}
2323
}
2424

ext/spl/examples/directorytreeiterator.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DirectoryTreeIterator extends RecursiveIteratorIterator
2121
*/
2222
function __construct($path)
2323
{
24-
parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
24+
parent::__construct(new RecursiveCachingIterator(new RecursiveDirectoryIterator($path), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
2525
}
2626

2727
/** @return the current element prefixed with ASCII graphics

ext/spl/examples/recursivearrayiterator.inc renamed to ext/spl/internal/recursivearrayiterator.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* SPL - Standard PHP Library
1010
*/
1111

12-
/** @ingroup Examples
12+
/** @ingroup SPL
1313
* @brief A recursive array iterator
1414
* @author Marcus Boerger
1515
* @version 1.0

ext/spl/internal/cachingrecursiveiterator.inc renamed to ext/spl/internal/recursivecachingiterator.inc

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
/** @file cachingrecursiveiterator.inc
3+
/** @file recursivecachingiterator.inc
44
* @ingroup SPL
5-
* @brief class CachingRecursiveIterator
5+
* @brief class RecursiveCachingIterator
66
* @author Marcus Boerger
77
* @date 2003 - 2005
88
*
@@ -12,12 +12,12 @@
1212
/**
1313
* @brief Cached recursive iteration over another Iterator
1414
* @author Marcus Boerger
15-
* @version 1.1
16-
* @since PHP 5.0
15+
* @version 1.2
16+
* @since PHP 5.1
1717
*
1818
* @see CachingIterator
1919
*/
20-
class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
20+
class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
2121
{
2222
private $hasChildren;
2323
private $getChildren;
@@ -48,25 +48,34 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera
4848
*/
4949
function next()
5050
{
51-
if ($this->hasChildren = $this->it->hasChildren()) {
52-
try {
53-
//$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->flags);
54-
// workaround memleaks...
51+
if ($this->hasChildren = $this->it->hasChildren())
52+
{
53+
try
54+
{
5555
$child = $this->it->getChildren();
56-
$this->getChildren = new CachingRecursiveIterator($child, $this->flags);
56+
if (!$this->ref)
57+
{
58+
$this->ref = new ReflectionClass($this);
59+
}
60+
$this->getChildren = $ref->newInstance($child, $this->flags);
5761
}
58-
catch(Exception $e) {
59-
if (!$this->flags & self::CATCH_GET_CHILD) {
62+
catch(Exception $e)
63+
{
64+
if (!$this->flags & self::CATCH_GET_CHILD)
65+
{
6066
throw $e;
6167
}
6268
$this->hasChildren = false;
6369
$this->getChildren = NULL;
6470
}
65-
} else {
71+
} else
72+
{
6673
$this->getChildren = NULL;
6774
}
6875
parent::next();
6976
}
77+
78+
private $ref;
7079

7180
/** @return whether the current element has children
7281
* @note The check whether the Iterator for the children can be created was

ext/spl/php_spl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ PHP_FUNCTION(class_implements)
156156
SPL_ADD_CLASS(BadFunctionCallException, z_list, sub, allow, ce_flags); \
157157
SPL_ADD_CLASS(BadMethodCallException, z_list, sub, allow, ce_flags); \
158158
SPL_ADD_CLASS(CachingIterator, z_list, sub, allow, ce_flags); \
159-
SPL_ADD_CLASS(CachingRecursiveIterator, z_list, sub, allow, ce_flags); \
160159
SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
161160
SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \
162161
SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
@@ -175,6 +174,8 @@ PHP_FUNCTION(class_implements)
175174
SPL_ADD_CLASS(OverflowException, z_list, sub, allow, ce_flags); \
176175
SPL_ADD_CLASS(ParentIterator, z_list, sub, allow, ce_flags); \
177176
SPL_ADD_CLASS(RangeException, z_list, sub, allow, ce_flags); \
177+
SPL_ADD_CLASS(RecursiveArrayIterator, z_list, sub, allow, ce_flags); \
178+
SPL_ADD_CLASS(RecursiveCachingIterator, z_list, sub, allow, ce_flags); \
178179
SPL_ADD_CLASS(RecursiveDirectoryIterator, z_list, sub, allow, ce_flags); \
179180
SPL_ADD_CLASS(RecursiveFilterIterator, z_list, sub, allow, ce_flags); \
180181
SPL_ADD_CLASS(RecursiveIterator, z_list, sub, allow, ce_flags); \

ext/spl/spl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* - interface SeekableIterator implements Iterator
4141
* - class LimitIterator implements OuterIterator
4242
* - class CachingIterator implements OuterIterator
43-
* - class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
43+
* - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
4444
* - class IteratorIterator implements OuterIterator
4545
* - class NoRewindIterator implements OuterIterator
4646
* - class EmptyIterator implements Iterator

0 commit comments

Comments
 (0)