3v4l.org

run code in 500+ PHP versions simultaneously
<?php function traverse(array $items): Generator { if (!empty($items)) { yield $items[0]; array_shift($items); yield from traverse($items); } } $values = iterator_to_array(traverse(['a', 'b', 'c', 'd', 'e']), false); foreach ($values as $value) { echo $value, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/jWbt4
function name:  (null)
number of ops:  15
compiled vars:  !0 = $values, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                                   'iterator_to_array'
          1        INIT_FCALL                                                   'traverse'
          2        SEND_VAL                                                     <array>
          3        DO_FCALL                                          0  $2      
          4        SEND_VAR                                                     $2
          5        SEND_VAL                                                     <false>
          6        DO_ICALL                                             $3      
          7        ASSIGN                                                       !0, $3
   14     8      > FE_RESET_R                                           $5      !0, ->13
          9    > > FE_FETCH_R                                                   $5, !1, ->13
   15    10    >   ECHO                                                         !1
         11        ECHO                                                         '%0A'
   14    12      > JMP                                                          ->9
         13    >   FE_FREE                                                      $5
   16    14      > RETURN                                                       1

Function traverse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 15
filename:       /in/jWbt4
function name:  traverse
number of ops:  16
compiled vars:  !0 = $items
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        GENERATOR_CREATE                                             
    4     2        ISSET_ISEMPTY_CV                                     ~1      !0
          3        BOOL_NOT                                             ~2      ~1
          4      > JMPZ                                                         ~2, ->15
    5     5    >   FETCH_DIM_R                                          ~3      !0, 0
          6        YIELD                                                        ~3
    7     7        INIT_FCALL                                                   'array_shift'
          8        SEND_REF                                                     !0
          9        DO_ICALL                                                     
    8    10        INIT_FCALL_BY_NAME                                           'traverse'
         11        SEND_VAR_EX                                                  !0
         12        DO_FCALL                                          0  $6      
         13        YIELD_FROM                                           ~7      $6
         14        FREE                                                         ~7
   10    15    > > GENERATOR_RETURN                                             

End of function traverse

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
210.99 ms | 1945 KiB | 16 Q