3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { yield 1; return 42; yield 2; } $g = gen1(); foreach($g as $val1) { var_dump($val1); } var_dump($g->current()); var_dump($g->valid()); var_dump($g->getReturn()); foreach($g as $val2) { var_dump($val2); } var_dump($g->current()); var_dump($g->valid()); var_dump($g->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 9
filename:       /in/K2oAY
function name:  (null)
number of ops:  48
compiled vars:  !0 = $g, !1 = $val1, !2 = $val2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'gen1'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   10     3      > FE_RESET_R                                       $5      !0, ->9
          4    > > FE_FETCH_R                                               $5, !1, ->9
   11     5    >   INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   10     8      > JMP                                                      ->4
          9    >   FE_FREE                                                  $5
   13    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'current'
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
   14    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !0, 'valid'
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   15    20        INIT_FCALL                                               'var_dump'
         21        INIT_METHOD_CALL                                         !0, 'getReturn'
         22        DO_FCALL                                      0  $11     
         23        SEND_VAR                                                 $11
         24        DO_ICALL                                                 
   17    25      > FE_RESET_R                                       $13     !0, ->31
         26    > > FE_FETCH_R                                               $13, !2, ->31
   18    27    >   INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
   17    30      > JMP                                                      ->26
         31    >   FE_FREE                                                  $13
   20    32        INIT_FCALL                                               'var_dump'
         33        INIT_METHOD_CALL                                         !0, 'current'
         34        DO_FCALL                                      0  $15     
         35        SEND_VAR                                                 $15
         36        DO_ICALL                                                 
   21    37        INIT_FCALL                                               'var_dump'
         38        INIT_METHOD_CALL                                         !0, 'valid'
         39        DO_FCALL                                      0  $17     
         40        SEND_VAR                                                 $17
         41        DO_ICALL                                                 
   22    42        INIT_FCALL                                               'var_dump'
         43        INIT_METHOD_CALL                                         !0, 'getReturn'
         44        DO_FCALL                                      0  $19     
         45        SEND_VAR                                                 $19
         46        DO_ICALL                                                 
         47      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/K2oAY
function name:  gen1
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                                    1
    5     2      > GENERATOR_RETURN                                         
    6     3*       YIELD                                                    2
    7     4*     > GENERATOR_RETURN                                         

End of function gen1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.53 ms | 1403 KiB | 16 Q