3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; $y = yield 2; var_dump($x + $y); } /** function yieldFrom() { $iter = gen1(); foreach($iter as $val) { yield $val; } } /**/ /**/ function gen2() { yield from gen1(); } /**/ $g = gen2(); $g->send(10); $g->send(20); // foreach($g as $val) { var_dump($val); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tAFiK
function name:  (null)
number of ops:  10
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'gen2'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   24     3        INIT_METHOD_CALL                                         !0, 'send'
          4        SEND_VAL_EX                                              10
          5        DO_FCALL                                      0          
   25     6        INIT_METHOD_CALL                                         !0, 'send'
          7        SEND_VAL_EX                                              20
          8        DO_FCALL                                      0          
   26     9      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/tAFiK
function name:  gen1
number of ops:  10
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                            $2      1
          2        ASSIGN                                                   !0, $2
    5     3        YIELD                                            $4      2
          4        ASSIGN                                                   !1, $4
    6     5        INIT_FCALL                                               'var_dump'
          6        ADD                                              ~6      !0, !1
          7        SEND_VAL                                                 ~6
          8        DO_ICALL                                                 
    7     9      > GENERATOR_RETURN                                         

End of function gen1

Function gen2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/tAFiK
function name:  gen2
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   GENERATOR_CREATE                                         
   19     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   20     5      > GENERATOR_RETURN                                         

End of function gen2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.5 ms | 1398 KiB | 17 Q