3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateAndConsume() { yield 1; yield 2; yield; var_dump(yield); var_dump(yield); } $g = generateAndConsume(); foreach ($g as $v) { if (!$v) break; var_dump($v); } $g->send(3); $g->send(4);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 12
filename:       /in/BKMLm
function name:  (null)
number of ops:  20
compiled vars:  !0 = $g, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'generateandconsume'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   12     3      > FE_RESET_R                                       $4      !0, ->12
          4    > > FE_FETCH_R                                               $4, !1, ->12
   13     5    >   BOOL_NOT                                         ~5      !1
          6      > JMPZ                                                     ~5, ->8
          7    > > JMP                                                      ->12
   14     8    >   INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   12    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $4
   16    13        INIT_METHOD_CALL                                         !0, 'send'
         14        SEND_VAL_EX                                              3
         15        DO_FCALL                                      0          
   17    16        INIT_METHOD_CALL                                         !0, 'send'
         17        SEND_VAL_EX                                              4
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function generateandconsume:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/BKMLm
function name:  generateAndConsume
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                                    1
    5     2        YIELD                                                    2
    6     3        YIELD                                                    
    7     4        INIT_FCALL                                               'var_dump'
          5        YIELD                                            $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
    8     8        INIT_FCALL                                               'var_dump'
          9        YIELD                                            $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                                 
    9    12      > GENERATOR_RETURN                                         

End of function generateandconsume

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.86 ms | 1399 KiB | 16 Q