3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { for ($i = 0; $i < 5; ++$i) { //get a value from the caller $cmd = (yield $i); var_dump($cmd); if($cmd == 'stop') { return;//exit the function } } } $gen = nums(); foreach($gen as $v) { if($v == 3) { $send = $gen->send('stop'); } if (isset($send)) var_dump($send); echo "{$v}\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
Branch analysis from position: 11
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/FjkDS
function name:  (null)
number of ops:  22
compiled vars:  !0 = $gen, !1 = $v, !2 = $send
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'nums'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   16     3      > FE_RESET_R                                       $5      !0, ->20
          4    > > FE_FETCH_R                                               $5, !1, ->20
   18     5    >   IS_EQUAL                                                 !1, 3
          6      > JMPZ                                                     ~6, ->11
   19     7    >   INIT_METHOD_CALL                                         !0, 'send'
          8        SEND_VAL_EX                                              'stop'
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   22    11    >   ISSET_ISEMPTY_CV                                         !2
         12      > JMPZ                                                     ~9, ->16
         13    >   INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
   24    16    >   NOP                                                      
         17        FAST_CONCAT                                      ~11     !1, '%0A'
         18        ECHO                                                     ~11
   16    19      > JMP                                                      ->4
         20    >   FE_FREE                                                  $5
   25    21      > RETURN                                                   1

Function nums:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
Branch analysis from position: 3
filename:       /in/FjkDS
function name:  nums
number of ops:  15
compiled vars:  !0 = $i, !1 = $cmd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->12
    6     3    >   YIELD                                            $3      !0
          4        ASSIGN                                                   !1, $3
    8     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
    9     8        IS_EQUAL                                                 !1, 'stop'
          9      > JMPZ                                                     ~6, ->11
   10    10    > > GENERATOR_RETURN                                         
    4    11    >   PRE_INC                                                  !0
         12    >   IS_SMALLER                                               !0, 5
         13      > JMPNZ                                                    ~8, ->3
   13    14    > > GENERATOR_RETURN                                         

End of function nums

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.85 ms | 1407 KiB | 16 Q