3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Source: https://bugs.php.net/bug.php?id=64979 function new_closure_gen() { return function() { static $foo = 0; //return array(++$foo); yield ++$foo; }; } $closure1 = new_closure_gen(); $closure2 = new_closure_gen(); $gen1 = $closure1(); $gen2 = $closure1(); $gen3 = $closure2(); foreach (array($gen1, $gen2, $gen3) as $gen) { foreach ($gen as $val) { print "$val\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/PLYQE
function name:  (null)
number of ops:  30
compiled vars:  !0 = $closure1, !1 = $closure2, !2 = $gen1, !3 = $gen2, !4 = $gen3, !5 = $gen, !6 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'new_closure_gen'
          1        DO_FCALL                                      0  $7      
          2        ASSIGN                                                   !0, $7
   13     3        INIT_FCALL                                               'new_closure_gen'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   15     6        INIT_DYNAMIC_CALL                                        !0
          7        DO_FCALL                                      0  $11     
          8        ASSIGN                                                   !2, $11
   16     9        INIT_DYNAMIC_CALL                                        !0
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !3, $13
   17    12        INIT_DYNAMIC_CALL                                        !1
         13        DO_FCALL                                      0  $15     
         14        ASSIGN                                                   !4, $15
   19    15        INIT_ARRAY                                       ~17     !2
         16        ADD_ARRAY_ELEMENT                                ~17     !3
         17        ADD_ARRAY_ELEMENT                                ~17     !4
         18      > FE_RESET_R                                       $18     ~17, ->28
         19    > > FE_FETCH_R                                               $18, !5, ->28
   20    20    > > FE_RESET_R                                       $19     !5, ->26
         21    > > FE_FETCH_R                                               $19, !6, ->26
   21    22    >   NOP                                                      
         23        FAST_CONCAT                                      ~20     !6, '%0A'
         24        ECHO                                                     ~20
   20    25      > JMP                                                      ->21
         26    >   FE_FREE                                                  $19
   19    27      > JMP                                                      ->19
         28    >   FE_FREE                                                  $18
   23    29      > RETURN                                                   1

Function new_closure_gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PLYQE
function name:  new_closure_gen
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FPLYQE%3A5%240'
    9     1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function new_closure_gen

Function %00%7Bclosure%7D%2Fin%2FPLYQE%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/PLYQE
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   GENERATOR_CREATE                                         
    6     1        BIND_STATIC                                              !0
    8     2        PRE_INC                                          ~1      !0
          3        YIELD                                                    ~1
    9     4      > GENERATOR_RETURN                                         

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.97 ms | 1403 KiB | 15 Q