3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myGeneratorFunction($foo) { $bar = yield from factoredComputation1($foo); $baz = yield from factoredComputation2($bar); return $baz; } function factoredComputation1($foo) { yield 1; yield 2; return 'zanzibar'; } function factoredComputation2($bar) { yield 3; yield 4; return 42; } $gen = myGeneratorFunction("Sup"); foreach($gen as $val) { var_dump($val); } var_dump($gen->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/6Nrah
function name:  (null)
number of ops:  17
compiled vars:  !0 = $gen, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'mygeneratorfunction'
          1        SEND_VAL                                                 'Sup'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   23     4      > FE_RESET_R                                       $4      !0, ->10
          5    > > FE_FETCH_R                                               $4, !1, ->10
   24     6    >   INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   23     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $4
   26    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getReturn'
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function mygeneratorfunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/6Nrah
function name:  myGeneratorFunction
number of ops:  14
compiled vars:  !0 = $foo, !1 = $bar, !2 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2        INIT_FCALL_BY_NAME                                       'factoredComputation1'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        YIELD_FROM                                       ~4      $3
          6        ASSIGN                                                   !1, ~4
    5     7        INIT_FCALL_BY_NAME                                       'factoredComputation2'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $6      
         10        YIELD_FROM                                       ~7      $6
         11        ASSIGN                                                   !2, ~7
    7    12      > GENERATOR_RETURN                                         
    8    13*     > GENERATOR_RETURN                                         

End of function mygeneratorfunction

Function factoredcomputation1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/6Nrah
function name:  factoredComputation1
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   11     2        YIELD                                                    1
   12     3        YIELD                                                    2
   13     4      > GENERATOR_RETURN                                         
   14     5*     > GENERATOR_RETURN                                         

End of function factoredcomputation1

Function factoredcomputation2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/6Nrah
function name:  factoredComputation2
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   17     2        YIELD                                                    3
   18     3        YIELD                                                    4
   19     4      > GENERATOR_RETURN                                         
   20     5*     > GENERATOR_RETURN                                         

End of function factoredcomputation2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.66 ms | 1403 KiB | 16 Q