xref: /PHP-8.1/ext/spl/tests/iterator_068.phpt (revision b3e08881)
1--TEST--
2SPL: Iterator: Overloaded object and destruction
3--FILE--
4<?php
5
6class Test implements Iterator {
7    function foo() {
8        echo __METHOD__ . "()\n";
9    }
10    function rewind(): void {}
11    function valid(): bool {}
12    function current(): mixed {}
13    function key(): mixed {}
14    function next(): void {}
15}
16
17class TestIteratorIterator extends IteratorIterator {
18    function __destruct() {
19        echo __METHOD__ . "()\n";
20        $this->foo();
21    }
22}
23
24$obj = new TestIteratorIterator(new Test);
25$obj->foo();
26unset($obj);
27
28?>
29--EXPECT--
30Test::foo()
31TestIteratorIterator::__destruct()
32Test::foo()
33