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; } } $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($g->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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 12
filename:       /in/mLTVL
function name:  (null)
number of ops:  34
compiled vars:  !0 = $a, !1 = $g, !2 = $num, !3 = $g2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $4      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   18     3        INIT_METHOD_CALL                                         !0, 'Gen'
          4        DO_FCALL                                      0  $7      
          5        ASSIGN                                                   !1, $7
   19     6      > FE_RESET_R                                       $9      !1, ->12
          7    > > FE_FETCH_R                                               $9, !2, ->12
          8    >   INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > JMP                                                      ->7
         12    >   FE_FREE                                                  $9
   20    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !1, 'getReturn'
         15        DO_FCALL                                      0  $11     
         16        SEND_VAR                                                 $11
         17        DO_ICALL                                                 
   22    18        INIT_STATIC_METHOD_CALL                                  'A', 'SGen'
         19        DO_FCALL                                      0  $13     
         20        ASSIGN                                                   !3, $13
   23    21      > FE_RESET_R                                       $15     !3, ->27
         22    > > FE_FETCH_R                                               $15, !2, ->27
         23    >   INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > JMP                                                      ->22
         27    >   FE_FREE                                                  $15
   24    28        INIT_FCALL                                               'var_dump'
         29        INIT_METHOD_CALL                                         !1, 'getReturn'
         30        DO_FCALL                                      0  $17     
         31        SEND_VAR                                                 $17
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Class A:
Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/mLTVL
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/mLTVL
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:
151.25 ms | 1400 KiB | 15 Q