3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function Gen() { var_dump($this); yield 1; yield 2; yield 3; return 11; } public static function SGen() { var_dump(get_called_class()); yield 4; yield 5; yield 6; return 22; } } function basicGen() { yield 7; yield 8; return 33; } function noReturnGen() { yield 9; yield 10; } $a = new A(); $g = $a->Gen(); foreach ($g as $num) { var_dump($num); } var_dump($g->getReturn()); $g2 = A::SGen(); foreach ($g2 as $num) { var_dump($num); } var_dump($g2->getReturn()); $g3 = basicGen(); foreach ($g3 as $num) { var_dump($num); } var_dump($g3->getReturn()); $g4 = noReturnGen(); foreach ($g4 as $num) { var_dump($num); } var_dump($g4->getReturn());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
2 jumps found. (Code = 78) Position 1 = 53, Position 2 = 57
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 12
filename:       /in/uT2NS
function name:  (null)
number of ops:  64
compiled vars:  !0 = $a, !1 = $g, !2 = $num, !3 = $g2, !4 = $g3, !5 = $g4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $6      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   27     3        INIT_METHOD_CALL                                         !0, 'Gen'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   28     6      > FE_RESET_R                                       $11     !1, ->12
          7    > > FE_FETCH_R                                               $11, !2, ->12
          8    >   INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > JMP                                                      ->7
         12    >   FE_FREE                                                  $11
   29    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !1, 'getReturn'
         15        DO_FCALL                                      0  $13     
         16        SEND_VAR                                                 $13
         17        DO_ICALL                                                 
   31    18        INIT_STATIC_METHOD_CALL                                  'A', 'SGen'
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !3, $15
   32    21      > FE_RESET_R                                       $17     !3, ->27
         22    > > FE_FETCH_R                                               $17, !2, ->27
         23    >   INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > JMP                                                      ->22
         27    >   FE_FREE                                                  $17
   33    28        INIT_FCALL                                               'var_dump'
         29        INIT_METHOD_CALL                                         !3, 'getReturn'
         30        DO_FCALL                                      0  $19     
         31        SEND_VAR                                                 $19
         32        DO_ICALL                                                 
   35    33        INIT_FCALL                                               'basicgen'
         34        DO_FCALL                                      0  $21     
         35        ASSIGN                                                   !4, $21
   36    36      > FE_RESET_R                                       $23     !4, ->42
         37    > > FE_FETCH_R                                               $23, !2, ->42
         38    >   INIT_FCALL                                               'var_dump'
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                                 
         41      > JMP                                                      ->37
         42    >   FE_FREE                                                  $23
   37    43        INIT_FCALL                                               'var_dump'
         44        INIT_METHOD_CALL                                         !4, 'getReturn'
         45        DO_FCALL                                      0  $25     
         46        SEND_VAR                                                 $25
         47        DO_ICALL                                                 
   39    48        INIT_FCALL                                               'noreturngen'
         49        DO_FCALL                                      0  $27     
         50        ASSIGN                                                   !5, $27
   40    51      > FE_RESET_R                                       $29     !5, ->57
         52    > > FE_FETCH_R                                               $29, !2, ->57
         53    >   INIT_FCALL                                               'var_dump'
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                                 
         56      > JMP                                                      ->52
         57    >   FE_FREE                                                  $29
   41    58        INIT_FCALL                                               'var_dump'
         59        INIT_METHOD_CALL                                         !5, 'getReturn'
         60        DO_FCALL                                      0  $31     
         61        SEND_VAR                                                 $31
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Function basicgen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/uT2NS
function name:  basicGen
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   GENERATOR_CREATE                                         
   18     1        YIELD                                                    7
          2        YIELD                                                    8
   19     3      > GENERATOR_RETURN                                         
   20     4*     > GENERATOR_RETURN                                         

End of function basicgen

Function noreturngen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/uT2NS
function name:  noReturnGen
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   GENERATOR_CREATE                                         
   23     1        YIELD                                                    9
          2        YIELD                                                    10
   24     3      > GENERATOR_RETURN                                         

End of function noreturngen

Class A:
Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/uT2NS
function name:  Gen
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   GENERATOR_CREATE                                         
    5     1        INIT_FCALL                                               'var_dump'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
    6     5        YIELD                                                    1
          6        YIELD                                                    2
          7        YIELD                                                    3
    7     8      > GENERATOR_RETURN                                         
    8     9*     > GENERATOR_RETURN                                         

End of function gen

Function sgen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/uT2NS
function name:  SGen
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
   11     1        INIT_FCALL                                               'var_dump'
          2        GET_CALLED_CLASS                                 ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   12     5        YIELD                                                    4
          6        YIELD                                                    5
          7        YIELD                                                    6
   13     8      > GENERATOR_RETURN                                         
   14     9*     > GENERATOR_RETURN                                         

End of function sgen

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.09 ms | 1407 KiB | 17 Q