3v4l.org

run code in 300+ PHP versions simultaneously
<?php function routeIterator(&$path) { while (!empty($path)) { yield $path[0]; array_shift($path); } } function exampleGenerator($path) { foreach ($routeIterator($path) as $chunk) { yield "Chunk: " . $chunk; echo " Sent value: " . yield . "\n"; } } foreach (exampleGenerator([1,2,3,4,5]) as $signal) { echo $signal; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/R6uop
function name:  (null)
number of ops:  9
compiled vars:  !0 = $signal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'examplegenerator'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $1      
          3      > FE_RESET_R                                       $2      $1, ->7
          4    > > FE_FETCH_R                                               $2, !0, ->7
   18     5    >   ECHO                                                     !0
   17     6      > JMP                                                      ->4
          7    >   FE_FREE                                                  $2
   19     8      > RETURN                                                   1

Function routeiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/R6uop
function name:  routeIterator
number of ops:  12
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > JMP                                                      ->8
    5     3    >   FETCH_DIM_R                                      ~1      !0, 0
          4        YIELD                                                    ~1
    6     5        INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
    4     8    >   ISSET_ISEMPTY_CV                                 ~4      !0
          9        BOOL_NOT                                         ~5      ~4
         10      > JMPNZ                                                    ~5, ->3
    8    11    > > GENERATOR_RETURN                                         

End of function routeiterator

Function examplegenerator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
filename:       /in/R6uop
function name:  exampleGenerator
number of ops:  16
compiled vars:  !0 = $path, !1 = $routeIterator, !2 = $chunk
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   11     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5      > FE_RESET_R                                       $4      $3, ->14
          6    > > FE_FETCH_R                                               $4, !2, ->14
   12     7    >   CONCAT                                           ~5      'Chunk%3A+', !2
          8        YIELD                                                    ~5
   13     9        YIELD                                            $7      
         10        CONCAT                                           ~8      '+Sent+value%3A+', $7
         11        CONCAT                                           ~9      ~8, '%0A'
         12        ECHO                                                     ~9
   11    13      > JMP                                                      ->6
         14    >   FE_FREE                                                  $4
   15    15      > GENERATOR_RETURN                                         

End of function examplegenerator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.15 ms | 1403 KiB | 16 Q