3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_to_ten() { yield 1; yield 3 => 2; $cmd = yield from [3, 4]; if ($cmd == 't') { echo "close"; return false; } yield yield from new ArrayIterator([5, 6]); yield from seven_eight(); return yield from nine_ten(); } function seven_eight() { yield 7; yield from eight(); } function eight() { yield 8; } function nine_ten() { yield 9; return 10; } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo "$k -> $num \n"; //echo $gen->send('t'); } var_dump( $gen->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/CRvJl
function name:  (null)
number of ops:  19
compiled vars:  !0 = $gen, !1 = $num, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'count_to_ten'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   32     3      > FE_RESET_R                                       $5      !0, ->12
          4    > > FE_FETCH_R                                       ~6      $5, !1, ->12
          5    >   ASSIGN                                                   !2, ~6
   33     6        ROPE_INIT                                     4  ~9      !2
          7        ROPE_ADD                                      1  ~9      ~9, '+-%3E+'
          8        ROPE_ADD                                      2  ~9      ~9, !1
          9        ROPE_END                                      3  ~8      ~9, '+%0A'
         10        ECHO                                                     ~8
   32    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $5
   36    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'getReturn'
         15        DO_FCALL                                      0  $11     
         16        SEND_VAR                                                 $11
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function count_to_ten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/CRvJl
function name:  count_to_ten
number of ops:  23
compiled vars:  !0 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                                    1
    5     2        YIELD                                                    2, 3
    6     3        YIELD_FROM                                       ~3      <array>
          4        ASSIGN                                                   !0, ~3
    7     5        IS_EQUAL                                                 !0, 't'
          6      > JMPZ                                                     ~5, ->9
    8     7    >   ECHO                                                     'close'
    9     8      > GENERATOR_RETURN                                         
   12     9    >   NEW                                              $6      'ArrayIterator'
         10        SEND_VAL_EX                                              <array>
         11        DO_FCALL                                      0          
         12        YIELD_FROM                                       ~8      $6
         13        YIELD                                                    ~8
   13    14        INIT_FCALL_BY_NAME                                       'seven_eight'
         15        DO_FCALL                                      0  $10     
         16        YIELD_FROM                                       ~11     $10
         17        FREE                                                     ~11
   14    18        INIT_FCALL_BY_NAME                                       'nine_ten'
         19        DO_FCALL                                      0  $12     
         20        YIELD_FROM                                       ~13     $12
         21      > GENERATOR_RETURN                                         
   15    22*     > GENERATOR_RETURN                                         

End of function count_to_ten

Function seven_eight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/CRvJl
function name:  seven_eight
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   GENERATOR_CREATE                                         
   18     1        YIELD                                                    7
   19     2        INIT_FCALL_BY_NAME                                       'eight'
          3        DO_FCALL                                      0  $1      
          4        YIELD_FROM                                       ~2      $1
          5        FREE                                                     ~2
   20     6      > GENERATOR_RETURN                                         

End of function seven_eight

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

End of function eight

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

End of function nine_ten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.67 ms | 1394 KiB | 16 Q