3v4l.org

run code in 300+ PHP versions simultaneously
<?php function yieldAll(array $total) { if (!version_compare(phpversion(), '5.5.0', '>=') && !defined('HHVM_VERSION')) { throw new DomainException(__FUNCTION__.' works only with a PHP version that supports Generators'); } 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/3MiRL
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
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'yieldall'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !1, $5
   19     5      > FE_RESET_R                                       $7      !1, ->16
          6    > > FE_FETCH_R                                       ~8      $7, !2, ->16
          7    >   ASSIGN                                                   !3, ~8
   20     8        IS_EQUAL                                                 !3, 1
          9      > JMPZ                                                     ~10, ->13
   21    10    >   INIT_METHOD_CALL                                         !1, 'send'
         11        SEND_VAL_EX                                              <false>
         12        DO_FCALL                                      0          
   23    13    >   ASSIGN_DIM                                               !0, !3
         14        OP_DATA                                                  !2
   19    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $7
   26    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 = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 29
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 14
filename:       /in/3MiRL
function name:  yieldAll
number of ops:  31
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        INIT_FCALL                                               'version_compare'
          3        INIT_FCALL                                               'phpversion'
          4        DO_ICALL                                         $4      
          5        SEND_VAR                                                 $4
          6        SEND_VAL                                                 '5.5.0'
          7        SEND_VAL                                                 '%3E%3D'
          8        DO_ICALL                                         $5      
          9        BOOL_NOT                                         ~6      $5
         10      > JMPZ_EX                                          ~6      ~6, ->14
         11    >   DEFINED                                          ~7      'HHVM_VERSION'
         12        BOOL_NOT                                         ~8      ~7
         13        BOOL                                             ~6      ~8
         14    > > JMPZ                                                     ~6, ->19
    6    15    >   NEW                                              $9      'DomainException'
         16        SEND_VAL_EX                                              'yieldAll+works+only+with+a+PHP+version+that+supports+Generators'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $9
    9    19    > > FE_RESET_R                                       $11     !0, ->29
         20    > > FE_FETCH_R                                       ~12     $11, !1, ->29
         21    >   ASSIGN                                                   !2, ~12
   10    22        YIELD                                            $14     !1, !2
         23        ASSIGN                                                   !3, $14
   11    24        BOOL_NOT                                         ~16     !3
         25      > JMPZ                                                     ~16, ->28
   12    26    >   FE_FREE                                                  $11
         27      > GENERATOR_RETURN                                         
    9    28    > > JMP                                                      ->20
         29    >   FE_FREE                                                  $11
   15    30      > GENERATOR_RETURN                                         

End of function yieldall

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.48 ms | 1403 KiB | 20 Q