1--TEST-- 2Duplicate of zend test tests/classes/iterators_002.phpt without expected output from destructor 3--FILE-- 4<?php 5class c_iter implements Iterator { 6 7 private $obj; 8 private $num = 0; 9 10 function __construct($obj) { 11 echo __METHOD__ . "\n"; 12 $this->obj = $obj; 13 } 14 function rewind() { 15 echo __METHOD__ . "\n"; 16 $this->num = 0; 17 } 18 function valid() { 19 $more = $this->num < $this->obj->max; 20 echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; 21 return $more; 22 } 23 function current() { 24 echo __METHOD__ . "\n"; 25 return $this->num; 26 } 27 function next() { 28 echo __METHOD__ . "\n"; 29 $this->num++; 30 } 31 function key() { 32 echo __METHOD__ . "\n"; 33 switch($this->num) { 34 case 0: return "1st"; 35 case 1: return "2nd"; 36 case 2: return "3rd"; 37 default: return "???"; 38 } 39 } 40 function __destruct() { 41 } 42} 43 44class c implements IteratorAggregate { 45 46 public $max = 3; 47 48 function getIterator() { 49 echo __METHOD__ . "\n"; 50 return new c_iter($this); 51 } 52 function __destruct() { 53 } 54} 55 56$t = new c(); 57 58foreach($t as $k => $v) { 59 foreach($t as $w) { 60 echo "double:$v:$w\n"; 61 break; 62 } 63} 64 65unset($t); 66 67?> 68===DONE=== 69--EXPECT-- 70c::getIterator 71c_iter::__construct 72c_iter::rewind 73c_iter::valid = true 74c_iter::current 75c_iter::key 76c::getIterator 77c_iter::__construct 78c_iter::rewind 79c_iter::valid = true 80c_iter::current 81double:0:0 82c_iter::next 83c_iter::valid = true 84c_iter::current 85c_iter::key 86c::getIterator 87c_iter::__construct 88c_iter::rewind 89c_iter::valid = true 90c_iter::current 91double:1:0 92c_iter::next 93c_iter::valid = true 94c_iter::current 95c_iter::key 96c::getIterator 97c_iter::__construct 98c_iter::rewind 99c_iter::valid = true 100c_iter::current 101double:2:0 102c_iter::next 103c_iter::valid = false 104===DONE=== 105