3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public static $transport = array(); public function do_stuff() { $test = self::get_transport(); return $test->do_stuff(); } protected static function get_transport(){ $tests = array( 'Test_this', 'Test_that' ); foreach( $tests as $class ) { $result = call_user_func(array($class, 'test')); if ($result) { self::$transport[] = $class; break; } } return new self::$transport[0](); } } class Test_this { public function do_stuff(){ return "this"; } public static function test(){ return false; } } class Test_that { public function do_stuff(){ return "that"; } public static function test(){ return true; } } $a = new Test; var_dump( $a->do_stuff() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  (null)
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   48     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'do_stuff'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class Test:
Function do_stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  do_stuff
number of ops:  7
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'get_transport'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
    8     3        INIT_METHOD_CALL                                         !0, 'do_stuff'
          4        DO_FCALL                                      0  $3      
          5      > RETURN                                                   $3
    9     6*     > RETURN                                                   null

End of function do_stuff

Function get_transport:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 14
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
Branch analysis from position: 14
filename:       /in/UeFGd
function name:  get_transport
number of ops:  22
compiled vars:  !0 = $tests, !1 = $class, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, <array>
   13     1      > FE_RESET_R                                       $4      !0, ->14
          2    > > FE_FETCH_R                                               $4, !1, ->14
   14     3    >   INIT_ARRAY                                       ~5      !1
          4        ADD_ARRAY_ELEMENT                                ~5      'test'
          5        INIT_USER_CALL                                0          'call_user_func', ~5
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   15     8      > JMPZ                                                     !2, ->13
   16     9    >   FETCH_STATIC_PROP_W          global              $8      'transport'
         10        ASSIGN_DIM                                               $8
         11        OP_DATA                                                  !1
   17    12      > JMP                                                      ->14
   13    13    > > JMP                                                      ->2
         14    >   FE_FREE                                                  $4
   20    15        FETCH_STATIC_PROP_R          unknown             ~10     'transport'
         16        FETCH_DIM_R                                      ~11     ~10, 0
         17        FETCH_CLASS                                   0  $12     ~11
         18        NEW                                              $13     $12
         19        DO_FCALL                                      0          
         20      > RETURN                                                   $13
   21    21*     > RETURN                                                   null

End of function get_transport

End of class Test.

Class Test_this:
Function do_stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  do_stuff
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E > > RETURN                                                   'this'
   28     1*     > RETURN                                                   null

End of function do_stuff

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E > > RETURN                                                   <false>
   32     1*     > RETURN                                                   null

End of function test

End of class Test_this.

Class Test_that:
Function do_stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  do_stuff
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E > > RETURN                                                   'that'
   39     1*     > RETURN                                                   null

End of function do_stuff

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeFGd
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E > > RETURN                                                   <true>
   43     1*     > RETURN                                                   null

End of function test

End of class Test_that.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.22 ms | 1405 KiB | 15 Q