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--EXPECT--
69c::getIterator
70c_iter::__construct
71c_iter::rewind
72c_iter::valid = true
73c_iter::current
74c_iter::key
75c::getIterator
76c_iter::__construct
77c_iter::rewind
78c_iter::valid = true
79c_iter::current
80double:0:0
81c_iter::next
82c_iter::valid = true
83c_iter::current
84c_iter::key
85c::getIterator
86c_iter::__construct
87c_iter::rewind
88c_iter::valid = true
89c_iter::current
90double:1:0
91c_iter::next
92c_iter::valid = true
93c_iter::current
94c_iter::key
95c::getIterator
96c_iter::__construct
97c_iter::rewind
98c_iter::valid = true
99c_iter::current
100double:2:0
101c_iter::next
102c_iter::valid = false
103