3v4l.org

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

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

End of function generateandconsume

Generated using Vulcan Logic Dumper, using php 7.3.0