]> granicus.if.org Git - php/commitdiff
- Fix issue with RecursiveArrayIterator::getChildren()
authorMarcus Boerger <helly@php.net>
Mon, 3 Oct 2005 09:12:39 +0000 (09:12 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 3 Oct 2005 09:12:39 +0000 (09:12 +0000)
ext/spl/examples/class_tree.php
ext/spl/internal/recursivearrayiterator.inc
ext/spl/spl_array.c

index 128eebec58cf4ad2c11e1ffc0ea834498eda41a8..07741a7dd873b4d72774787529ea376bc10c321e 100755 (executable)
@@ -62,11 +62,6 @@ class SubClasses extends RecursiveArrayIterator
                }
        }
        
-       function getChildren()
-       {
-               return parent::current();
-       }
-       
        function current()
        {
                return parent::key();
index 1b4497afd800c0bc6b584a49e3883bca636a3178..e583c734b4164774a6b0faaccc468aca498ca0d4 100755 (executable)
@@ -13,7 +13,7 @@
  * @brief   A recursive array iterator
  * @author  Marcus Boerger
  * @version 1.0
- * @since PHP 6.0
+ * @since PHP 5.1
  *
  * Passes the RecursiveIterator interface to the inner Iterator and provides
  * the same functionality as FilterIterator. This allows you to skip parents
@@ -42,6 +42,10 @@ class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
         */
        function getChildren()
        {
+               if ($this->current() instanceof self)
+               {
+                       return $this->current();
+               }
                if (empty($this->ref))
                {
                        $this->ref = new ReflectionClass($this);
index b954b225692f0d9fb6df2d01b71a56e17f15942a..cd75a161d2882c6d7ce213fe9b31c513bfa8c915 100755 (executable)
@@ -1204,6 +1204,10 @@ SPL_METHOD(Array, getChildren)
                return;
        }
 
+       if (Z_TYPE_PP(entry) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(entry), Z_OBJCE_P(getThis()) TSRMLS_CC)) {
+               RETURN_ZVAL(*entry, 0, 0);
+       }
+
        spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, *entry TSRMLS_CC);
 }
 /* }}} */