3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ParentClass { public function foo() { echo __CLASS__, "\n"; echo get_class($this), "\n"; echo "\n"; } } class ChildClass extends ParentClass { public function foo() { echo __CLASS__, "\n"; echo get_class($this), "\n"; echo "\n"; } } $obj = new ChildClass(); // bind closure to $obj and use scope resolution operator (function () { ParentClass::foo(); })->call($obj); // use reflection (new \ReflectionMethod(ParentClass::class, 'foo'))->invoke($obj); // dg magic call_user_func([$obj, 'ParentClass::foo']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vW3Yh
function name:  (null)
number of ops:  19
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $1      'ChildClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvW3Yh%3A26%240'
          4        INIT_METHOD_CALL                                         ~4, 'call'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   29     7        NEW                                              $6      'ReflectionMethod'
          8        SEND_VAL_EX                                              'ParentClass'
          9        SEND_VAL_EX                                              'foo'
         10        DO_FCALL                                      0          
         11        INIT_METHOD_CALL                                         $6, 'invoke'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   32    14        INIT_ARRAY                                       ~9      !0
         15        ADD_ARRAY_ELEMENT                                ~9      'ParentClass%3A%3Afoo'
         16        INIT_USER_CALL                                0          'call_user_func', ~9
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvW3Yh%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vW3Yh
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_STATIC_METHOD_CALL                                  'ParentClass', 'foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvW3Yh%3A26%240

Class ParentClass:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vW3Yh
function name:  foo
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     'ParentClass'
          1        ECHO                                                     '%0A'
    8     2        FETCH_THIS                                       ~0      
          3        GET_CLASS                                        ~1      ~0
          4        ECHO                                                     ~1
          5        ECHO                                                     '%0A'
    9     6        ECHO                                                     '%0A'
   10     7      > RETURN                                                   null

End of function foo

End of class ParentClass.

Class ChildClass:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vW3Yh
function name:  foo
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'ChildClass'
          1        ECHO                                                     '%0A'
   18     2        FETCH_THIS                                       ~0      
          3        GET_CLASS                                        ~1      ~0
          4        ECHO                                                     ~1
          5        ECHO                                                     '%0A'
   19     6        ECHO                                                     '%0A'
   20     7      > RETURN                                                   null

End of function foo

End of class ChildClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.85 ms | 1399 KiB | 13 Q