1--TEST--
2IteratorAggregate::getIterator bad return type
3--FILE--
4<?php
5
6class bad1 implements IteratorAggregate {
7    #[ReturnTypeWillChange]
8    function getIterator() {
9        return null;
10    }
11}
12
13class bad2 implements IteratorAggregate {
14    #[ReturnTypeWillChange]
15    function getIterator() {
16        return new stdClass;
17    }
18}
19
20class bad3 implements IteratorAggregate {
21    #[ReturnTypeWillChange]
22    function getIterator() {
23        return 1;
24    }
25}
26
27class bad4 implements IteratorAggregate {
28    #[ReturnTypeWillChange]
29    function getIterator() {
30        return array(1,2,3);
31    }
32}
33
34
35function f($className) {
36    try {
37        foreach (new $className as $k=>$v) {
38            echo "$k => $v\n";
39        }
40    } catch (Exception $e) {
41            echo $e->getLine() . ": " . $e->getMessage() ."\n";
42    }
43}
44
45f("bad1");
46f("bad2");
47f("bad3");
48f("bad4");
49
50?>
51--EXPECT--
5234: Objects returned by bad1::getIterator() must be traversable or implement interface Iterator
5334: Objects returned by bad2::getIterator() must be traversable or implement interface Iterator
5434: Objects returned by bad3::getIterator() must be traversable or implement interface Iterator
5534: Objects returned by bad4::getIterator() must be traversable or implement interface Iterator
56