xref: /PHP-7.0/Zend/tests/bug32993.phpt (revision 610c7fbe)
1--TEST--
2Bug #32993 (implemented Iterator function current() don't throw exception)
3--FILE--
4<?php
5class Test implements Iterator {
6
7    public $arr = array();
8
9    public function rewind()    { return reset($this->arr); }
10    public function current()   { throw new Exception(); }
11    public function key()       { return key($this->arr); }
12    public function next()      { return next($this->arr); }
13    public function valid()     { return (current($this->arr) !== false); }
14}
15
16$t = new Test();
17$t->arr =  array(1, 2, 3);
18
19try {
20    foreach ($t as $v) {
21        echo "$v\n";
22    }
23} catch (Exception $e) {
24    ; // handle exception
25}
26echo "ok\n";
27?>
28--EXPECT--
29ok
30