sccp_032.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. SCCP 032: Yield from optimizations
  3. --INI--
  4. opcache.enable=1
  5. opcache.enable_cli=1
  6. opcache.optimization_level=-1
  7. opcache.opt_debug_level=0x20000
  8. opcache.preload=
  9. --EXTENSIONS--
  10. opcache
  11. --FILE--
  12. <?php
  13. function test(): Generator {
  14. $result = yield from [];
  15. $a = [];
  16. yield from $a;
  17. yield $result;
  18. $a[] = 3;
  19. yield from $a;
  20. }
  21. foreach (test() as $x) {
  22. var_export($x);
  23. echo "\n";
  24. }
  25. ?>
  26. --EXPECTF--
  27. $_main:
  28. ; (lines=11, args=0, vars=1, tmps=2)
  29. ; (after optimizer)
  30. ; %ssccp_032.php:1-15
  31. 0000 INIT_FCALL 0 %d string("test")
  32. 0001 V2 = DO_UCALL
  33. 0002 V1 = FE_RESET_R V2 0009
  34. 0003 FE_FETCH_R V1 CV0($x) 0009
  35. 0004 INIT_FCALL 1 %d string("var_export")
  36. 0005 SEND_VAR CV0($x) 1
  37. 0006 DO_ICALL
  38. 0007 ECHO string("
  39. ")
  40. 0008 JMP 0003
  41. 0009 FE_FREE V1
  42. 0010 RETURN int(1)
  43. LIVE RANGES:
  44. 1: 0003 - 0009 (loop)
  45. test:
  46. ; (lines=5, args=0, vars=0, tmps=1)
  47. ; (after optimizer)
  48. ; %ssccp_032.php:2-9
  49. 0000 GENERATOR_CREATE
  50. 0001 YIELD null
  51. 0002 T0 = YIELD_FROM array(...)
  52. 0003 FREE T0
  53. 0004 GENERATOR_RETURN null
  54. NULL
  55. 3