bug32993.phpt 686 B

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