yield_from_backtrace.phpt 817 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Exceptions in linear yield from setup
  3. --FILE--
  4. <?php
  5. function from($off) {
  6. debug_print_backtrace();
  7. yield $off + 1;
  8. }
  9. function gen() {
  10. yield 1;
  11. debug_print_backtrace();
  12. yield 2;
  13. yield from from(2);
  14. debug_print_backtrace();
  15. }
  16. print "\nImplicit foreach:\n";
  17. foreach (gen() as $v) {
  18. var_dump($v);
  19. }
  20. print "\nExplicit iterator:\n";
  21. for ($gen = gen(); $gen->valid(); $gen->next()) {
  22. var_dump($gen->current());
  23. }
  24. ?>
  25. --EXPECTF--
  26. Implicit foreach:
  27. int(1)
  28. #0 gen() called at [%s:%d]
  29. int(2)
  30. #0 from(2) called at [%s:%d]
  31. #1 gen() called at [%s:%d]
  32. int(3)
  33. #0 gen() called at [%s:%d]
  34. Explicit iterator:
  35. int(1)
  36. #0 gen()
  37. #1 Generator->next() called at [%s:%d]
  38. int(2)
  39. #0 from(2) called at [%s:%d]
  40. #1 gen()
  41. #2 Generator->next() called at [%s:%d]
  42. int(3)
  43. #0 gen()
  44. #1 Generator->next() called at [%s:%d]