3v4l.org

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


preferences:
150.38 ms | 1013 KiB | 15 Q