3v4l.org

run code in 500+ PHP versions simultaneously
<?php function generator() { foreach ([1, 2, 3, 4, 5] as $i) { yield $i; } } function A(): \Generator { return generator(); } function B(): \Generator { if (false) { yield 7; return; } return generator(); } function C(): \Generator { if (false) { yield 7; return; } foreach (generator() as $i) { yield $i; } } echo "-A\n"; foreach (A() as $i) { echo "{$i}\n"; } echo "-B\n"; foreach (B() as $i) { echo "{$i}\n"; } echo "-C\n"; foreach (C() as $i) { echo "{$i}\n"; } echo "Done\n";
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 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 19
Branch analysis from position: 9
filename:       /in/e86mK
function name:  (null)
number of ops:  32
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                         '-A%0A'
   32     1        INIT_FCALL                                                   'a'
          2        DO_FCALL                                          0  $1      
          3      > FE_RESET_R                                           $2      $1, ->9
          4    > > FE_FETCH_R                                                   $2, !0, ->9
   33     5    >   NOP                                                          
          6        FAST_CONCAT                                          ~3      !0, '%0A'
          7        ECHO                                                         ~3
   32     8      > JMP                                                          ->4
          9    >   FE_FREE                                                      $2
   36    10        ECHO                                                         '-B%0A'
   37    11        INIT_FCALL                                                   'b'
         12        DO_FCALL                                          0  $4      
         13      > FE_RESET_R                                           $5      $4, ->19
         14    > > FE_FETCH_R                                                   $5, !0, ->19
   38    15    >   NOP                                                          
         16        FAST_CONCAT                                          ~6      !0, '%0A'
         17        ECHO                                                         ~6
   37    18      > JMP                                                          ->14
         19    >   FE_FREE                                                      $5
   41    20        ECHO                                                         '-C%0A'
   42    21        INIT_FCALL                                                   'c'
         22        DO_FCALL                                          0  $7      
         23      > FE_RESET_R                                           $8      $7, ->29
         24    > > FE_FETCH_R                                                   $8, !0, ->29
   43    25    >   NOP                                                          
         26        FAST_CONCAT                                          ~9      !0, '%0A'
         27        ECHO                                                         ~9
   42    28      > JMP                                                          ->24
         29    >   FE_FREE                                                      $8
   46    30        ECHO                                                         'Done%0A'
         31      > RETURN                                                       1

Function generator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 5
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 5
filename:       /in/e86mK
function name:  generator
number of ops:  7
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                             
    4     1      > FE_RESET_R                                           $1      <array>, ->5
          2    > > FE_FETCH_R                                                   $1, !0, ->5
    5     3    >   YIELD                                                        !0
    4     4      > JMP                                                          ->2
          5    >   FE_FREE                                                      $1
    7     6      > GENERATOR_RETURN                                             

End of function generator

Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e86mK
function name:  A
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                                   'generator'
          1        DO_FCALL                                          0  $0      
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   11     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function a

Function b:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/e86mK
function name:  B
number of ops:  8
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                             
   14     1      > JMPZ                                                         <false>, ->4
   15     2    >   YIELD                                                        7
   16     3      > GENERATOR_RETURN                                             
   18     4    >   INIT_FCALL                                                   'generator'
          5        DO_FCALL                                          0  $1      
          6      > GENERATOR_RETURN                                             
   19     7*     > GENERATOR_RETURN                                             

End of function b

Function c:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 10
filename:       /in/e86mK
function name:  C
number of ops:  12
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   GENERATOR_CREATE                                             
   22     1      > JMPZ                                                         <false>, ->4
   23     2    >   YIELD                                                        7
   24     3      > GENERATOR_RETURN                                             
   26     4    >   INIT_FCALL                                                   'generator'
          5        DO_FCALL                                          0  $2      
          6      > FE_RESET_R                                           $3      $2, ->10
          7    > > FE_FETCH_R                                                   $3, !0, ->10
   27     8    >   YIELD                                                        !0
   26     9      > JMP                                                          ->7
         10    >   FE_FREE                                                      $3
   29    11      > GENERATOR_RETURN                                             

End of function c

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.78 ms | 487 KiB | 13 Q