3v4l.org

run code in 300+ PHP versions simultaneously
<?php function yieldAll(array $total) { foreach ($total as $key => $value) { $stmt = (yield $key => $value); if (! $stmt) { return; } } } $toto = []; $res = yieldAll(['toto', 'tata', 'tutu']); foreach ($res as $key => $value) { if (1 == $key) { $res->send(false); } $toto[$key] = $value; } var_dump($toto);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/8SsXj
function name:  (null)
number of ops:  21
compiled vars:  !0 = $toto, !1 = $res, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL                                               'yieldall'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !1, $5
   15     5      > FE_RESET_R                                       $7      !1, ->16
          6    > > FE_FETCH_R                                       ~8      $7, !2, ->16
          7    >   ASSIGN                                                   !3, ~8
   16     8        IS_EQUAL                                                 !3, 1
          9      > JMPZ                                                     ~10, ->13
   17    10    >   INIT_METHOD_CALL                                         !1, 'send'
         11        SEND_VAL_EX                                              <false>
         12        DO_FCALL                                      0          
   19    13    >   ASSIGN_DIM                                               !0, !3
         14        OP_DATA                                                  !2
   15    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $7
   22    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function yieldall:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 12
filename:       /in/8SsXj
function name:  yieldAll
number of ops:  14
compiled vars:  !0 = $total, !1 = $value, !2 = $key, !3 = $stmt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    5     2      > FE_RESET_R                                       $4      !0, ->12
          3    > > FE_FETCH_R                                       ~5      $4, !1, ->12
          4    >   ASSIGN                                                   !2, ~5
    6     5        YIELD                                            $7      !1, !2
          6        ASSIGN                                                   !3, $7
    7     7        BOOL_NOT                                         ~9      !3
          8      > JMPZ                                                     ~9, ->11
    8     9    >   FE_FREE                                                  $4
         10      > GENERATOR_RETURN                                         
    5    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $4
   11    13      > GENERATOR_RETURN                                         

End of function yieldall

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.35 ms | 1403 KiB | 16 Q