3v4l.org

run code in 500+ PHP versions simultaneously
<?php $function = function () { yield 0; }; $wrapper = function () use ($function) { $generator = $function(); $generator->valid(); yield from $generator; $generator = $function(); // Comment out this line to get the correct result. $generator->valid(); yield from $generator; }; foreach ($wrapper() as $value) { echo $value; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/GfJHG
function name:  (null)
number of ops:  13
compiled vars:  !0 = $function, !1 = $wrapper, !2 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          1        ASSIGN                                                       !0, ~3
    7     2        DECLARE_LAMBDA_FUNCTION                              ~5      [1]
          3        BIND_LEXICAL                                                 ~5, !0
          4        ASSIGN                                                       !1, ~5
   18     5        INIT_DYNAMIC_CALL                                            !1
          6        DO_FCALL                                          0  $7      
          7      > FE_RESET_R                                           $8      $7, ->11
          8    > > FE_FETCH_R                                                   $8, !2, ->11
   19     9    >   ECHO                                                         !2
   18    10      > JMP                                                          ->8
         11    >   FE_FREE                                                      $8
   20    12      > RETURN                                                       1


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

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/GfJHG
function name:  {closure:/in/GfJHG:7}
number of ops:  17
compiled vars:  !0 = $function, !1 = $generator
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   GENERATOR_CREATE                                             
          1        BIND_STATIC                                                  !0
    8     2        INIT_DYNAMIC_CALL                                            !0
          3        DO_FCALL                                          0  $2      
          4        ASSIGN                                                       !1, $2
    9     5        INIT_METHOD_CALL                                             !1, 'valid'
          6        DO_FCALL                                          0          
   10     7        YIELD_FROM                                           ~5      !1
          8        FREE                                                         ~5
   12     9        INIT_DYNAMIC_CALL                                            !0
         10        DO_FCALL                                          0  $6      
         11        ASSIGN                                                       !1, $6
   14    12        INIT_METHOD_CALL                                             !1, 'valid'
         13        DO_FCALL                                          0          
   15    14        YIELD_FROM                                           ~9      !1
         15        FREE                                                         ~9
   16    16      > GENERATOR_RETURN                                             

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.86 ms | 2277 KiB | 13 Q