3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { yield 1; yield 2; return 42; } function gen2() { yield 3; yield 4; } function genEarlyReturn() { return 23; yield 2; } function testGen($g) { $g1 = gen1(); foreach($g1 as $val) { var_dump($val); } echo "Returning\n"; var_dump($g1->getReturn()); } testGen(gen1()); testGen(gen2()); testGen(genEarlyReturn());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z6cM9
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'testgen'
          1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_FCALL                                      0          
   29     5        INIT_FCALL                                               'testgen'
          6        INIT_FCALL                                               'gen2'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_FCALL                                      0          
   30    10        INIT_FCALL                                               'testgen'
         11        INIT_FCALL                                               'genearlyreturn'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

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

End of function gen2

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

End of function genearlyreturn

Function testgen:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/Z6cM9
function name:  testGen
number of ops:  18
compiled vars:  !0 = $g, !1 = $g1, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   21     4      > FE_RESET_R                                       $5      !1, ->10
          5    > > FE_FETCH_R                                               $5, !2, ->10
   22     6    >   INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   21     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $5
   24    11        ECHO                                                     'Returning%0A'
   25    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'getReturn'
         14        DO_FCALL                                      0  $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                                 
   26    17      > RETURN                                                   null

End of function testgen

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.99 ms | 1407 KiB | 22 Q