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