3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['item', '2']; $b = (function () use ($a) { foreach ($a as $item) { yield $item; } })(); while ($b->valid()) { var_dump($b->current()); $b->next(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
Branch analysis from position: 7
filename:       /in/1j783
function name:  (null)
number of ops:  18
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1j783%3A5%240'
          2        BIND_LEXICAL                                             ~3, !0
    9     3        INIT_DYNAMIC_CALL                                        ~3
          4        DO_FCALL                                      0  $4      
    5     5        ASSIGN                                                   !1, $4
   11     6      > JMP                                                      ->14
   12     7    >   INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !1, 'current'
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                                 
   13    12        INIT_METHOD_CALL                                         !1, 'next'
         13        DO_FCALL                                      0          
   11    14    >   INIT_METHOD_CALL                                         !1, 'valid'
         15        DO_FCALL                                      0  $9      
         16      > JMPNZ                                                    $9, ->7
   14    17    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F1j783%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/1j783
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   GENERATOR_CREATE                                         
          1        BIND_STATIC                                              !0
    6     2      > FE_RESET_R                                       $2      !0, ->6
          3    > > FE_FETCH_R                                               $2, !1, ->6
    7     4    >   YIELD                                                    !1
    6     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $2
    9     7      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2F1j783%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.08 ms | 1401 KiB | 15 Q