3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen() { yield 0; yield 1; yield 2; } $gen = (function(){ $foo = gen(); $foo->rewind(); $foo->valid(); yield $foo->key() => $foo->current(); $foo->next(); $foo->valid(); yield $foo->key() => $foo->current(); yield from $foo; })(); foreach($gen as $k => $v){ echo $k . " => " . $v . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/RFVZ3
function name:  (null)
number of ops:  14
compiled vars:  !0 = $gen, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FRFVZ3%3A11%240'
   20     1        INIT_DYNAMIC_CALL                                        ~3
          2        DO_FCALL                                      0  $4      
   11     3        ASSIGN                                                   !0, $4
   23     4      > FE_RESET_R                                       $6      !0, ->12
          5    > > FE_FETCH_R                                       ~7      $6, !1, ->12
          6    >   ASSIGN                                                   !2, ~7
   24     7        CONCAT                                           ~9      !2, '+%3D%3E+'
          8        CONCAT                                           ~10     ~9, !1
          9        CONCAT                                           ~11     ~10, '%0A'
         10        ECHO                                                     ~11
   23    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $6
   25    13      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/RFVZ3
function name:  gen
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   GENERATOR_CREATE                                         
    6     1        YIELD                                                    0
    7     2        YIELD                                                    1
    8     3        YIELD                                                    2
    9     4      > GENERATOR_RETURN                                         

End of function gen

Function %00%7Bclosure%7D%2Fin%2FRFVZ3%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/RFVZ3
function name:  {closure}
number of ops:  25
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   GENERATOR_CREATE                                         
   12     1        INIT_FCALL                                               'gen'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   13     4        INIT_METHOD_CALL                                         !0, 'rewind'
          5        DO_FCALL                                      0          
   14     6        INIT_METHOD_CALL                                         !0, 'valid'
          7        DO_FCALL                                      0          
   15     8        INIT_METHOD_CALL                                         !0, 'key'
          9        DO_FCALL                                      0  $5      
         10        INIT_METHOD_CALL                                         !0, 'current'
         11        DO_FCALL                                      0  $6      
         12        YIELD                                                    $6, $5
   16    13        INIT_METHOD_CALL                                         !0, 'next'
         14        DO_FCALL                                      0          
   17    15        INIT_METHOD_CALL                                         !0, 'valid'
         16        DO_FCALL                                      0          
   18    17        INIT_METHOD_CALL                                         !0, 'key'
         18        DO_FCALL                                      0  $10     
         19        INIT_METHOD_CALL                                         !0, 'current'
         20        DO_FCALL                                      0  $11     
         21        YIELD                                                    $11, $10
   19    22        YIELD_FROM                                       ~13     !0
         23        FREE                                                     ~13
   20    24      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FRFVZ3%3A11%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.41 ms | 1403 KiB | 14 Q