3v4l.org

run code in 300+ PHP versions simultaneously
<?php // proof of concept: call method from parents parent class A { private $value = 'please override me'; public function set() { $this->value = 'A was here'; } public function get() { return $this->value; } } class B extends A { public function set() { // do nothing, value is "please override me" } } class C extends B { public function set() { (new ReflectionClass($this))->getParentClass()->getParentClass()->getMethod('set')->getClosure($this)(); } } // as reference, B::set() was overridden: $b = new B; $b->set(); var_dump($b->get()); // "please override me" // and now parent::parent::set() :) $c = new C; $c->set(); var_dump($c->get()); // "A was here"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  (null)
number of ops:  21
compiled vars:  !0 = $b, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $2      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   38     3        INIT_METHOD_CALL                                         !0, 'set'
          4        DO_FCALL                                      0          
   39     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'get'
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   42    10        NEW                                              $8      'C'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $8
   43    13        INIT_METHOD_CALL                                         !1, 'set'
         14        DO_FCALL                                      0          
   44    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !1, 'get'
         17        DO_FCALL                                      0  $12     
         18        SEND_VAR                                                 $12
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class A:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  set
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN_OBJ                                               'value'
          1        OP_DATA                                                  'A+was+here'
   12     2      > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function get

End of class A.

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

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function get

End of class B.

Class C:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  set
number of ops:  18
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $0      'ReflectionClass'
          1        FETCH_THIS                                       $1      
          2        SEND_VAR_EX                                              $1
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'getParentClass'
          5        DO_FCALL                                      0  $3      
          6        INIT_METHOD_CALL                                         $3, 'getParentClass'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'getMethod'
          9        SEND_VAL_EX                                              'set'
         10        DO_FCALL                                      0  $5      
         11        INIT_METHOD_CALL                                         $5, 'getClosure'
         12        FETCH_THIS                                       $6      
         13        SEND_VAR_EX                                              $6
         14        DO_FCALL                                      0  $7      
         15        INIT_DYNAMIC_CALL                                        $7
         16        DO_FCALL                                      0          
   33    17      > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ZuqD
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function get

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.07 ms | 1392 KiB | 15 Q