summaryrefslogtreecommitdiff
path: root/Zend/tests/bug32993.phpt
blob: 88fb0230b6bd555013051af7c172cc25cae2bb4a (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
--TEST--
Bug #32993 (implemented Iterator function current() don't throw exception)
--FILE--
<?php
class Test implements Iterator {

    public $arr = array();

    public function rewind()    { return reset($this->arr); }
    public function current()   { throw new Exception(); }
    public function key()       { return key($this->arr); }
    public function next()      { return next($this->arr); }
    public function valid()     { return (current($this->arr) !== false); }
}

$t = new Test();
$t->arr =  array(1, 2, 3);

try {
    foreach ($t as $v) {
        echo "$v\n";
    }
} catch (Exception $e) {
    ; // handle exception
}
echo "ok\n";
?>
--EXPECT--
ok