3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = function () { var_dump('foo'); yield 1; yield 2; yield 3; }; $iterator = new CachingIterator($foo()); foreach ($iterator as $value) { var_dump($value); } foreach ($iterator as $value) { var_dump($value); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 14
filename:       /in/dgAFs
function name:  (null)
number of ops:  23
compiled vars:  !0 = $foo, !1 = $iterator, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdgAFs%3A3%240'
          1        ASSIGN                                                   !0, ~3
   10     2        NEW                                              $5      'CachingIterator'
          3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0  $6      
          5        SEND_VAR_NO_REF_EX                                       $6
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   12     8      > FE_RESET_R                                       $9      !1, ->14
          9    > > FE_FETCH_R                                               $9, !2, ->14
   13    10    >   INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   12    13      > JMP                                                      ->9
         14    >   FE_FREE                                                  $9
   16    15      > FE_RESET_R                                       $11     !1, ->21
         16    > > FE_FETCH_R                                               $11, !2, ->21
   17    17    >   INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
   16    20      > JMP                                                      ->16
         21    >   FE_FREE                                                  $11
   18    22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdgAFs%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/dgAFs
function name:  {closure}
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'foo'
          3        DO_ICALL                                                 
    5     4        YIELD                                                    1
    6     5        YIELD                                                    2
    7     6        YIELD                                                    3
    8     7      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FdgAFs%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.69 ms | 1400 KiB | 15 Q