3v4l.org

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

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

End of function nine_ten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.04 ms | 1403 KiB | 16 Q