3v4l.org

run code in 500+ PHP versions simultaneously
<?php function arrayProvider() { yield [ 'one', 'two', 'three', ]; yield [ 'four', 'five', 'six', ]; yield [ 'seven', 'eight', 'nine', ]; } function iterateValues(array $array) { foreach ($array as $value) { yield $value; } } function g1() { foreach (arrayProvider() as $array) { $iterator = iterateValues($array); if ($iterator?->valid()) { yield from $iterator; } } } function g2() { yield from g1(); } foreach (g2() as $s) { echo $s . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/GdcNh
function name:  (null)
number of ops:  9
compiled vars:  !0 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   INIT_FCALL                                                   'g2'
          1        DO_FCALL                                          0  $1      
          2      > FE_RESET_R                                           $2      $1, ->7
          3    > > FE_FETCH_R                                                   $2, !0, ->7
   46     4    >   CONCAT                                               ~3      !0, '%0A'
          5        ECHO                                                         ~3
   45     6      > JMP                                                          ->3
          7    >   FE_FREE                                                      $2
   47     8      > RETURN                                                       1

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

End of function arrayprovider

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

End of function iteratevalues

Function g1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 16
filename:       /in/GdcNh
function name:  g1
number of ops:  18
compiled vars:  !0 = $array, !1 = $iterator
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   GENERATOR_CREATE                                             
   32     1        INIT_FCALL                                                   'arrayprovider'
          2        DO_FCALL                                          0  $2      
          3      > FE_RESET_R                                           $3      $2, ->16
          4    > > FE_FETCH_R                                                   $3, !0, ->16
   33     5    >   INIT_FCALL                                                   'iteratevalues'
          6        SEND_VAR                                                     !0
          7        DO_FCALL                                          0  $4      
          8        ASSIGN                                                       !1, $4
   35     9        JMP_NULL                                             $6      !1
         10        INIT_METHOD_CALL                                             !1, 'valid'
         11        DO_FCALL                                          0  $6      
         12      > JMPZ                                                         $6, ->15
   36    13    >   YIELD_FROM                                           ~7      !1
         14        FREE                                                         ~7
   32    15    > > JMP                                                          ->4
         16    >   FE_FREE                                                      $3
   39    17      > GENERATOR_RETURN                                             

End of function g1

Function g2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/GdcNh
function name:  g2
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   41     0  E >   GENERATOR_CREATE                                             
   42     1        INIT_FCALL                                                   'g1'
          2        DO_FCALL                                          0  $0      
          3        YIELD_FROM                                           ~1      $0
          4        FREE                                                         ~1
   43     5      > GENERATOR_RETURN                                             

End of function g2

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
181.44 ms | 1035 KiB | 12 Q