Annotation of embedaddon/php/ext/spl/tests/iterator_014.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: RecursiveIteratorIterator and beginChildren/endChildren
! 3: --FILE--
! 4: <?php
! 5:
! 6: class MyRecursiveArrayIterator extends RecursiveArrayIterator
! 7: {
! 8: function valid()
! 9: {
! 10: if (!parent::valid())
! 11: {
! 12: echo __METHOD__ . " = false\n";
! 13: return false;
! 14: }
! 15: else
! 16: {
! 17: return true;
! 18: }
! 19: }
! 20:
! 21: function getChildren()
! 22: {
! 23: echo __METHOD__ . "\n";
! 24: return parent::getChildren();
! 25: }
! 26: }
! 27:
! 28: class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
! 29: {
! 30: function rewind()
! 31: {
! 32: echo __METHOD__ . "\n";
! 33: parent::rewind();
! 34: }
! 35:
! 36: function valid()
! 37: {
! 38: echo __METHOD__ . "\n";
! 39: return parent::valid();
! 40: }
! 41:
! 42: function current()
! 43: {
! 44: echo __METHOD__ . "\n";
! 45: return parent::current();
! 46: }
! 47:
! 48: function key()
! 49: {
! 50: echo __METHOD__ . "\n";
! 51: return parent::key();
! 52: }
! 53:
! 54: function next()
! 55: {
! 56: echo __METHOD__ . "\n";
! 57: parent::next();
! 58: }
! 59:
! 60: function beginChildren()
! 61: {
! 62: echo __METHOD__ . "(".$this->getDepth().")\n";
! 63: }
! 64:
! 65: function endChildren()
! 66: {
! 67: echo __METHOD__ . "(".$this->getDepth().")\n";
! 68: }
! 69: }
! 70:
! 71: foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"))) as $k=>$v)
! 72: {
! 73: echo "$k=>$v\n";
! 74: }
! 75: ?>
! 76: ===DONE===
! 77: <?php exit(0); ?>
! 78: --EXPECT--
! 79: RecursiveArrayIteratorIterator::rewind
! 80: RecursiveArrayIteratorIterator::valid
! 81: RecursiveArrayIteratorIterator::current
! 82: RecursiveArrayIteratorIterator::key
! 83: 0=>a
! 84: RecursiveArrayIteratorIterator::next
! 85: MyRecursiveArrayIterator::getChildren
! 86: RecursiveArrayIteratorIterator::beginChildren(1)
! 87: RecursiveArrayIteratorIterator::valid
! 88: RecursiveArrayIteratorIterator::current
! 89: RecursiveArrayIteratorIterator::key
! 90: 0=>ba
! 91: RecursiveArrayIteratorIterator::next
! 92: MyRecursiveArrayIterator::getChildren
! 93: RecursiveArrayIteratorIterator::beginChildren(2)
! 94: RecursiveArrayIteratorIterator::valid
! 95: RecursiveArrayIteratorIterator::current
! 96: RecursiveArrayIteratorIterator::key
! 97: 0=>bba
! 98: RecursiveArrayIteratorIterator::next
! 99: RecursiveArrayIteratorIterator::valid
! 100: RecursiveArrayIteratorIterator::current
! 101: RecursiveArrayIteratorIterator::key
! 102: 1=>bbb
! 103: RecursiveArrayIteratorIterator::next
! 104: MyRecursiveArrayIterator::valid = false
! 105: RecursiveArrayIteratorIterator::endChildren(2)
! 106: MyRecursiveArrayIterator::getChildren
! 107: RecursiveArrayIteratorIterator::beginChildren(2)
! 108: MyRecursiveArrayIterator::getChildren
! 109: RecursiveArrayIteratorIterator::beginChildren(3)
! 110: RecursiveArrayIteratorIterator::valid
! 111: RecursiveArrayIteratorIterator::current
! 112: RecursiveArrayIteratorIterator::key
! 113: 0=>bcaa
! 114: RecursiveArrayIteratorIterator::next
! 115: MyRecursiveArrayIterator::valid = false
! 116: RecursiveArrayIteratorIterator::endChildren(3)
! 117: MyRecursiveArrayIterator::valid = false
! 118: RecursiveArrayIteratorIterator::endChildren(2)
! 119: MyRecursiveArrayIterator::valid = false
! 120: RecursiveArrayIteratorIterator::endChildren(1)
! 121: MyRecursiveArrayIterator::getChildren
! 122: RecursiveArrayIteratorIterator::beginChildren(1)
! 123: RecursiveArrayIteratorIterator::valid
! 124: RecursiveArrayIteratorIterator::current
! 125: RecursiveArrayIteratorIterator::key
! 126: 0=>ca
! 127: RecursiveArrayIteratorIterator::next
! 128: MyRecursiveArrayIterator::valid = false
! 129: RecursiveArrayIteratorIterator::endChildren(1)
! 130: RecursiveArrayIteratorIterator::valid
! 131: RecursiveArrayIteratorIterator::current
! 132: RecursiveArrayIteratorIterator::key
! 133: 3=>d
! 134: RecursiveArrayIteratorIterator::next
! 135: MyRecursiveArrayIterator::valid = false
! 136: RecursiveArrayIteratorIterator::valid
! 137: MyRecursiveArrayIterator::valid = false
! 138: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>