bug52238.phpt 540 B

123456789101112131415161718192021222324
  1. --TEST--
  2. Bug #52238 - Crash when an Exception occurred in iterator_to_array
  3. --FILE--
  4. <?php
  5. class Foo implements IteratorAggregate
  6. {
  7. public function bar() {
  8. throw new Exception;
  9. }
  10. public function getIterator(): Traversable {
  11. return new ArrayIterator($this->bar());
  12. }
  13. }
  14. var_dump(iterator_to_array(new Foo));
  15. ?>
  16. --EXPECTF--
  17. Fatal error: Uncaught Exception in %s
  18. Stack trace:
  19. #0 %s: Foo->bar()
  20. #1 [internal function]: Foo->getIterator()
  21. #2 %s: iterator_to_array(Object(Foo))
  22. #3 {main}
  23. thrown in %s on line %d