3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &gen($vals) { $func = function ($i) {return $i; }; foreach($vals as $val) { yield $func($val); } } $values = [1, 2, 3, 4, 5]; foreach(gen($values) as &$value) { $value *= 2; } var_dump($values);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 126) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/VOYiT
function name:  (null)
number of ops:  14
compiled vars:  !0 = $values, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'gen'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        SEPARATE                                         $3      $3
          5      > FE_RESET_RW                                      $4      $3, ->9
          6    > > FE_FETCH_RW                                              $4, !1, ->9
   16     7    >   ASSIGN_OP                                     3          !1, 2
   15     8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $4
   19    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
filename:       /in/VOYiT
function name:  gen
number of ops:  13
compiled vars:  !0 = $vals, !1 = $func, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    6     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVOYiT%3A6%240'
          3        ASSIGN                                                   !1, ~3
    8     4      > FE_RESET_R                                       $5      !0, ->11
          5    > > FE_FETCH_R                                               $5, !2, ->11
    9     6    >   INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $6      
          9        YIELD                                                    $6
    8    10      > JMP                                                      ->5
         11    >   FE_FREE                                                  $5
   11    12      > GENERATOR_RETURN                                         

End of function gen

Function %00%7Bclosure%7D%2Fin%2FVOYiT%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOYiT
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1      > RETURN                                                   !0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVOYiT%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.61 ms | 1403 KiB | 16 Q