3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; echo "Sup!\n"; $y = yield 2; var_dump($x + $y); } function yfgenerator() { yield from gen1(); echo "Dawg\n"; yield from gen1(); yield from [1, 2, 3]; } function yfeiterator() { $arr = [1, 2, 3]; foreach($arr as $val) { yield $val; } } function yfiterator() { yield from []; yield from [1, 2, 3]; /**/ yield from array( "first" => 1, "second" => 2, "third" => 3, ); /**/ } function iterationTest($g) { echo "About to start iteration\n"; foreach($g as $key => $val) { echo "Iteration!\n"; var_dump($key); var_dump($val); } echo "Done with iteration\n"; } function sendingTest($g) { $g->next(); $g->send(10); $g->send(20); } iterationTest(yfiterator()); //iterationTest(yfeiterator()); // iterationTest(gen1()); echo "Done with all tests\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I1i17
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_FCALL                                               'iterationtest'
          1        INIT_FCALL                                               'yfiterator'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_FCALL                                      0          
   67     5        ECHO                                                     'Done+with+all+tests%0A'
          6      > RETURN                                                   1

Function gen1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/I1i17
function name:  gen1
number of ops:  11
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        YIELD                                            $2      1
          2        ASSIGN                                                   !0, $2
    5     3        ECHO                                                     'Sup%21%0A'
    6     4        YIELD                                            $4      2
          5        ASSIGN                                                   !1, $4
    7     6        INIT_FCALL                                               'var_dump'
          7        ADD                                              ~6      !0, !1
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
    8    10      > GENERATOR_RETURN                                         

End of function gen1

Function yfgenerator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/I1i17
function name:  yfgenerator
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   11     1        INIT_FCALL                                               'gen1'
          2        DO_FCALL                                      0  $0      
          3        YIELD_FROM                                       ~1      $0
          4        FREE                                                     ~1
   12     5        ECHO                                                     'Dawg%0A'
   13     6        INIT_FCALL                                               'gen1'
          7        DO_FCALL                                      0  $2      
          8        YIELD_FROM                                       ~3      $2
          9        FREE                                                     ~3
   14    10        YIELD_FROM                                       ~4      <array>
         11        FREE                                                     ~4
   15    12      > GENERATOR_RETURN                                         

End of function yfgenerator

Function yfeiterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/I1i17
function name:  yfeiterator
number of ops:  8
compiled vars:  !0 = $arr, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   GENERATOR_CREATE                                         
   18     1        ASSIGN                                                   !0, <array>
   19     2      > FE_RESET_R                                       $3      !0, ->6
          3    > > FE_FETCH_R                                               $3, !1, ->6
   20     4    >   YIELD                                                    !1
   19     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $3
   22     7      > GENERATOR_RETURN                                         

End of function yfeiterator

Function yfiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/I1i17
function name:  yfiterator
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   GENERATOR_CREATE                                         
   25     1        YIELD_FROM                                       ~0      <array>
          2        FREE                                                     ~0
   26     3        YIELD_FROM                                       ~1      <array>
          4        FREE                                                     ~1
   29     5        YIELD_FROM                                       ~2      <array>
          6        FREE                                                     ~2
   34     7      > GENERATOR_RETURN                                         

End of function yfiterator

Function iterationtest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/I1i17
function name:  iterationTest
number of ops:  16
compiled vars:  !0 = $g, !1 = $val, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   47     1        ECHO                                                     'About+to+start+iteration%0A'
   48     2      > FE_RESET_R                                       $3      !0, ->13
          3    > > FE_FETCH_R                                       ~4      $3, !1, ->13
          4    >   ASSIGN                                                   !2, ~4
   49     5        ECHO                                                     'Iteration%21%0A'
   50     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   51     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   48    12      > JMP                                                      ->3
         13    >   FE_FREE                                                  $3
   53    14        ECHO                                                     'Done+with+iteration%0A'
   54    15      > RETURN                                                   null

End of function iterationtest

Function sendingtest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I1i17
function name:  sendingTest
number of ops:  10
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
   57     1        INIT_METHOD_CALL                                         !0, 'next'
          2        DO_FCALL                                      0          
   58     3        INIT_METHOD_CALL                                         !0, 'send'
          4        SEND_VAL_EX                                              10
          5        DO_FCALL                                      0          
   59     6        INIT_METHOD_CALL                                         !0, 'send'
          7        SEND_VAL_EX                                              20
          8        DO_FCALL                                      0          
   60     9      > RETURN                                                   null

End of function sendingtest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.77 ms | 1407 KiB | 19 Q