throw_rethrow.phpt 645 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Generator::throw() where the generator throws a different exception
  3. --FILE--
  4. <?php
  5. function gen() {
  6. echo "before yield\n";
  7. try {
  8. yield;
  9. } catch (RuntimeException $e) {
  10. echo 'Caught: ', $e, "\n\n";
  11. throw new LogicException('new throw');
  12. }
  13. }
  14. $gen = gen();
  15. var_dump($gen->throw(new RuntimeException('throw')));
  16. ?>
  17. --EXPECTF--
  18. before yield
  19. Caught: RuntimeException: throw in %s:%d
  20. Stack trace:
  21. #0 {main}
  22. Fatal error: Uncaught LogicException: new throw in %s:%d
  23. Stack trace:
  24. #0 [internal function]: gen()
  25. #1 %s(%d): Generator->throw(Object(RuntimeException))
  26. #2 {main}
  27. thrown in %s on line %d