3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BaseClass { private static $queryClass = 'StaticSqlQuery'; public static function setQueryClass($className) { static::$queryClass = $className; } public static function test() { return forward_static_call([static::$queryClass, 'init']); } } class StaticSqlQuery { public static function init($tableName, $className) { return 'Original call'; } } echo BaseClass::test(); BaseClass::setQueryClass( get_class(new class extends StaticSQLQuery { public static function init($tableName, $className) { return 'My stub'; } }) ); echo BaseClass::test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTYrD
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'BaseClass', 'test'
          1        DO_FCALL                                      0  $0      
          2        ECHO                                                     $0
   24     3        INIT_STATIC_METHOD_CALL                                  'BaseClass', 'setQueryClass'
   25     4        DECLARE_ANON_CLASS                               <unknown> 'staticsqlquery'
          5        NEW                                              $2      $1
          6        DO_FCALL                                      0          
          7        GET_CLASS                                        ~4      $2
          8        SEND_VAL                                                 ~4
          9        DO_FCALL                                      0          
   33    10        INIT_STATIC_METHOD_CALL                                  'BaseClass', 'test'
         11        DO_FCALL                                      0  $6      
         12        ECHO                                                     $6
         13      > RETURN                                                   1

Class BaseClass:
Function setqueryclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTYrD
function name:  setQueryClass
number of ops:  4
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_STATIC_PROP                                       'queryClass'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function setqueryclass

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTYrD
function name:  test
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'forward_static_call'
          1        FETCH_STATIC_PROP_R          global lock         ~0      'queryClass'
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'init'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   13     7*     > RETURN                                                   null

End of function test

End of class BaseClass.

Class StaticSqlQuery:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTYrD
function name:  init
number of ops:  4
compiled vars:  !0 = $tableName, !1 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2      > RETURN                                                   'Original+call'
   19     3*     > RETURN                                                   null

End of function init

End of class StaticSqlQuery.

Class StaticSQLQuery@anonymous:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTYrD
function name:  init
number of ops:  4
compiled vars:  !0 = $tableName, !1 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2      > RETURN                                                   'My+stub'
   29     3*     > RETURN                                                   null

End of function init

End of class StaticSQLQuery@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.89 ms | 1400 KiB | 15 Q