cvs: php-src(PHP_5_0) / NEWS /ext/spl php_spl.c spl.php spl_iterators.c spl_iterators.h /ext/spl/examples directorytreeiterator.inc
/ext/spl/internal cachingrecursiveiterator.inc recursivecachingiterator.inc

From: Date: Mon, 19 Sep 2005 19:11:19 +0000
Subject: cvs: php-src(PHP_5_0) / NEWS /ext/spl php_spl.c spl.php spl_iterators.c spl_iterators.h /ext/spl/examples directorytreeiterator.inc
/ext/spl/internal cachingrecursiveiterator.inc recursivecachingiterator.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-34026@lists.php.net to get a copy of this message
helly Mon Sep 19 15:11:19 2005 EDT Added files: (Branch: PHP_5_0) /php-src/ext/spl/internal recursivecachingiterator.inc Modified files: /php-src NEWS /php-src/ext/spl php_spl.c spl.php spl_iterators.c spl_iterators.h /php-src/ext/spl/examples directorytreeiterator.inc /php-src/ext/spl/internal cachingrecursiveiterator.inc Log: - MFH Renamed CachingRecursiveIterator to RecursiveCachingIterator. # After talking to other developers it came clear that adding an upgrade # path by 'class CachingRecursiveIterator extends RecursiveCachingIterator' # with its constructor issuing an E_NOTICE seems a good idea.

http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.482&r2=1.1760.2.483&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.482 php-src/NEWS:1.1760.2.483 --- php-src/NEWS:1.1760.2.482 Mon Sep 19 14:51:34 2005 +++ php-src/NEWS Mon Sep 19 15:11:16 2005 @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 5.0.6 +- Renamed CachingRecursiveIterator to RecursiveCachingIterator. (Marcus) - Fixed bug #34478 (Incorrect parsing of url's fragment (#...)). (Dmitry) - Fixed bug #34450 (Segfault when calling mysqli_close() in destructor). (Tony) - Fixed bug #34449 (ext/soap: XSD_ANYXML functionality not exposed). (Dmitry) http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.28.2.1&r2=1.28.2.2&ty=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.28.2.1 php-src/ext/spl/php_spl.c:1.28.2.2 --- php-src/ext/spl/php_spl.c:1.28.2.1 Wed Aug 24 06:18:15 2005 +++ php-src/ext/spl/php_spl.c Mon Sep 19 15:11:18 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.28.2.1 2005/08/24 10:18:15 johannes Exp $ */ +/* $Id: php_spl.c,v 1.28.2.2 2005/09/19 19:11:18 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -160,11 +160,11 @@ SPL_ADD_CLASS(ArrayIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(ArrayObject, 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(DirectoryIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(FilterIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(LimitIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(ParentIterator, 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(RecursiveIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(RecursiveIteratorIterator, z_list, sub, allow, ce_flags); \ http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.25.2.2&r2=1.25.2.3&ty=u Index: php-src/ext/spl/spl.php diff -u php-src/ext/spl/spl.php:1.25.2.2 php-src/ext/spl/spl.php:1.25.2.3 --- php-src/ext/spl/spl.php:1.25.2.2 Fri Oct 1 06:36:50 2004 +++ php-src/ext/spl/spl.php Mon Sep 19 15:11:18 2005 @@ -424,7 +424,7 @@ /** \ingroup SPL * \brief The recursive version of the CachingIterator. */ -class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator +class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator { /** Construct an instance form a RecursiveIterator. * http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.38.2.10&r2=1.38.2.11&ty=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.38.2.10 php-src/ext/spl/spl_iterators.c:1.38.2.11 --- php-src/ext/spl/spl_iterators.c:1.38.2.10 Sat Mar 12 18:12:36 2005 +++ php-src/ext/spl/spl_iterators.c Mon Sep 19 15:11:18 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.c,v 1.38.2.10 2005/03/12 23:12:36 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.38.2.11 2005/09/19 19:11:18 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -44,6 +44,7 @@ zend_class_entry *spl_ce_LimitIterator; zend_class_entry *spl_ce_CachingIterator; zend_class_entry *spl_ce_CachingRecursiveIterator; +zend_class_entry *spl_ce_RecursiveCachingIterator; function_entry spl_funcs_RecursiveIterator[] = { SPL_ABSTRACT_ME(RecursiveIterator, hasChildren, NULL) @@ -586,7 +587,7 @@ break; } case DIT_CachingIterator: - case DIT_CachingRecursiveIterator: { + case DIT_RecursiveCachingIterator: { long flags = CIT_CALL_TOSTRING; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &zobject, ce_inner, &flags) == FAILURE) { php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); @@ -659,7 +660,7 @@ efree(intern->current.str_key); intern->current.str_key = NULL; } - if (intern->dit_type == DIT_CachingIterator || intern->dit_type == DIT_CachingRecursiveIterator) { + if (intern->dit_type == DIT_CachingIterator || intern->dit_type == DIT_RecursiveCachingIterator) { if (intern->u.caching.zstr) { zval_ptr_dtor(&intern->u.caching.zstr); intern->u.caching.zstr = NULL; @@ -1117,7 +1118,7 @@ { if (spl_dual_it_fetch(intern, 1 TSRMLS_CC) == SUCCESS) { intern->u.caching.flags |= CIT_VALID; - if (intern->dit_type == DIT_CachingRecursiveIterator) { + if (intern->dit_type == DIT_RecursiveCachingIterator) { zval *retval, *zchildren, zflags; zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval); if (zend_is_true(retval)) { @@ -1131,7 +1132,7 @@ } else { INIT_PZVAL(&zflags); ZVAL_LONG(&zflags, intern->u.caching.flags & CIT_PUBLIC); - spl_instantiate_arg_ex2(spl_ce_CachingRecursiveIterator, &intern->u.caching.zchildren, 1, zchildren, &zflags TSRMLS_CC); + spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator, &intern->u.caching.zchildren, 1, zchildren, &zflags TSRMLS_CC); zval_ptr_dtor(&zchildren); } } @@ -1280,16 +1281,16 @@ {NULL, NULL, NULL} }; -/* {{{ proto CachingRecursiveIterator::__construct(RecursiveIterator it [, flags = CIT_CALL_TOSTRING]) +/* {{{ proto RecursiveCachingIterator::__construct(RecursiveIterator it [, flags = CIT_CALL_TOSTRING]) Create an iterator from a RecursiveIterator */ -SPL_METHOD(CachingRecursiveIterator, __construct) +SPL_METHOD(RecursiveCachingIterator, __construct) { - spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_RecursiveIterator, DIT_CachingRecursiveIterator); + spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_RecursiveIterator, DIT_RecursiveCachingIterator); } /* }}} */ -/* {{{ proto bolean CachingRecursiveIterator::hasChildren() +/* {{{ proto bolean RecursiveCachingIterator::hasChildren() Check whether the current element of the inner iterator has children */ -SPL_METHOD(CachingRecursiveIterator, hasChildren) +SPL_METHOD(RecursiveCachingIterator, hasChildren) { spl_dual_it_object *intern; @@ -1298,9 +1299,9 @@ RETURN_BOOL(intern->u.caching.zchildren); } /* }}} */ -/* {{{ proto CachingRecursiveIterator CachingRecursiveIterator::getChildren() - Return the inner iterator's children as a CachingRecursiveIterator */ -SPL_METHOD(CachingRecursiveIterator, getChildren) +/* {{{ proto RecursiveCachingIterator RecursiveCachingIterator::getChildren() + Return the inner iterator's children as a RecursiveCachingIterator */ +SPL_METHOD(RecursiveCachingIterator, getChildren) { spl_dual_it_object *intern; @@ -1319,10 +1320,23 @@ ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO(); +static zend_function_entry spl_funcs_RecursiveCachingIterator[] = { + SPL_ME(RecursiveCachingIterator, __construct, arginfo_caching_rec_it___construct, ZEND_ACC_PUBLIC) + SPL_ME(RecursiveCachingIterator, hasChildren, NULL, ZEND_ACC_PUBLIC) + SPL_ME(RecursiveCachingIterator, getChildren, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +/* {{{ proto CachingRecursiveIterator::__construct(RecursiveIterator it [, flags = CIT_CALL_TOSTRING]) + Deprecated: Create an iterator from a RecursiveIterator */ +SPL_METHOD(CachingRecursiveIterator, __construct) +{ + spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_RecursiveIterator, DIT_RecursiveCachingIterator); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "CachingRecursiveIterator is deprecated, use RecursiveCachingIterator"); +} /* }}} */ + static zend_function_entry spl_funcs_CachingRecursiveIterator[] = { SPL_ME(CachingRecursiveIterator, __construct, arginfo_caching_rec_it___construct, ZEND_ACC_PUBLIC) - SPL_ME(CachingRecursiveIterator, hasChildren, NULL, ZEND_ACC_PUBLIC) - SPL_ME(CachingRecursiveIterator, getChildren, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; @@ -1370,9 +1384,11 @@ REGISTER_LONG_CONSTANT("CIT_CALL_TOSTRING", (long)CIT_CALL_TOSTRING, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CIT_CATCH_GET_CHILD", (long)CIT_CATCH_GET_CHILD, CONST_CS | CONST_PERSISTENT); - REGISTER_SPL_SUB_CLASS_EX(CachingRecursiveIterator, CachingIterator, spl_dual_it_new, spl_funcs_CachingRecursiveIterator); - REGISTER_SPL_IMPLEMENTS(CachingRecursiveIterator, RecursiveIterator); + REGISTER_SPL_SUB_CLASS_EX(RecursiveCachingIterator, CachingIterator, spl_dual_it_new, spl_funcs_RecursiveCachingIterator); + REGISTER_SPL_IMPLEMENTS(RecursiveCachingIterator, RecursiveIterator); + REGISTER_SPL_SUB_CLASS_EX(CachingRecursiveIterator, RecursiveCachingIterator, spl_dual_it_new, spl_funcs_CachingRecursiveIterator); + return SUCCESS; } /* }}} */ http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.h?r1=1.9&r2=1.9.2.1&ty=u Index: php-src/ext/spl/spl_iterators.h diff -u php-src/ext/spl/spl_iterators.h:1.9 php-src/ext/spl/spl_iterators.h:1.9.2.1 --- php-src/ext/spl/spl_iterators.h:1.9 Mon Mar 8 13:05:41 2004 +++ php-src/ext/spl/spl_iterators.h Mon Sep 19 15:11:18 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.h,v 1.9 2004/03/08 18:05:41 helly Exp $ */ +/* $Id: spl_iterators.h,v 1.9.2.1 2005/09/19 19:11:18 helly Exp $ */ #ifndef SPL_ITERATORS_H #define SPL_ITERATORS_H @@ -31,7 +31,7 @@ extern zend_class_entry *spl_ce_SeekableIterator; extern zend_class_entry *spl_ce_LimitIterator; extern zend_class_entry *spl_ce_CachingIterator; -extern zend_class_entry *spl_ce_CachingRecursiveIterator; +extern zend_class_entry *spl_ce_RecursiveCachingIterator; PHP_MINIT_FUNCTION(spl_iterators); @@ -39,7 +39,7 @@ DIT_Default = 0, DIT_LimitIterator, DIT_CachingIterator, - DIT_CachingRecursiveIterator + DIT_RecursiveCachingIterator } dual_it_type; enum { http://cvs.php.net/diff.php/php-src/ext/spl/examples/directorytreeiterator.inc?r1=1.12&r2=1.12.2.1&ty=u Index: php-src/ext/spl/examples/directorytreeiterator.inc diff -u php-src/ext/spl/examples/directorytreeiterator.inc:1.12 php-src/ext/spl/examples/directorytreeiterator.inc:1.12.2.1 --- php-src/ext/spl/examples/directorytreeiterator.inc:1.12 Mon May 10 13:26:03 2004 +++ php-src/ext/spl/examples/directorytreeiterator.inc Mon Sep 19 15:11:18 2005 @@ -21,7 +21,7 @@ */ function __construct($path) { - parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), CIT_CALL_TOSTRING|CIT_CATCH_GET_CHILD), 1); + parent::__construct(new RecursiveCachingIterator(new RecursiveDirectoryIterator($path), CIT_CALL_TOSTRING|CIT_CATCH_GET_CHILD), 1); } /** @return the current element prefixed with ASCII graphics http://cvs.php.net/diff.php/php-src/ext/spl/internal/cachingrecursiveiterator.inc?r1=1.1&r2=1.1.2.1&ty=u Index: php-src/ext/spl/internal/cachingrecursiveiterator.inc diff -u php-src/ext/spl/internal/cachingrecursiveiterator.inc:1.1 php-src/ext/spl/internal/cachingrecursiveiterator.inc:1.1.2.1 --- php-src/ext/spl/internal/cachingrecursiveiterator.inc:1.1 Sat May 8 08:24:15 2004 +++ php-src/ext/spl/internal/cachingrecursiveiterator.inc Mon Sep 19 15:11:19 2005 @@ -1,53 +1,28 @@ <?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(); - } +/** @file cachingrecursiveiterator.inc + * @ingroup Examples + * @brief class CachingRecursiveIterator + * @author Marcus Boerger + * @date 2003 - 2005 + * + * SPL - Standard PHP Library + */ - 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(); - } +/** @ingroup Examples + * @brief Compatibility to PHP 5.0 + * @author Marcus Boerger + * @version 1.2 + * @deprecated + * + * Class RecursiveCachingIterator was named CachingRecursiveIterator until + * PHP 5.0.6. + * + * @see RecursiveCachingIterator + */ - function hasChildren() - { - return $this->hasChildren; - } - - function getChildren() - { - return $this->getChildren; - } +class CachingRecursiveIterator extends RecursiveCachingIterator +{ } ?> \ No newline at end of file http://cvs.php.net/co.php/php-src/ext/spl/internal/recursivecachingiterator.inc?r=1.1&p=1 Index: php-src/ext/spl/internal/recursivecachingiterator.inc +++ php-src/ext/spl/internal/recursivecachingiterator.inc <?php /** @file recursivecachingiterator.inc * @ingroup SPL * @brief class RecursiveCachingIterator * @author Marcus Boerger * @date 2003 - 2005 * * SPL - Standard PHP Library */ /** * @brief Cached recursive iteration over another Iterator * @author Marcus Boerger * @version 1.2 * @since PHP 5.1 * * @see CachingIterator */ class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator { private $hasChildren; private $getChildren; /** Construct from another iterator * * @param it Iterator to cache * @param flags Bitmask: * - CALL_TOSTRING (whether to call __toString() for every element) * - CATCH_GET_CHILD (whether to catch exceptions when trying to get childs) */ function __construct(RecursiveIterator $it, $flags = self::CALL_TOSTRING) { parent::__construct($it, $flags); } /** Rewind Iterator */ function rewind(); { $this->hasChildren = false; $this->getChildren = NULL; parent::rewind(); } /** Forward to next element if necessary then an Iterator for the Children * will be created. */ function next() { if ($this->hasChildren = $this->it->hasChildren()) { try { $child = $this->it->getChildren(); 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) { throw $e; } $this->hasChildren = false; $this->getChildren = NULL; } } 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 * already executed. Hence when flag CATCH_GET_CHILD was given in * constructor this fucntion returns false so that getChildren does * not try to access those children. */ function hasChildren() { return $this->hasChildren; } /** @return An Iterator for the children */ function getChildren() { return $this->getChildren; } } ?>
« previous php.cvs (#34026) next »