3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); abstract class Base { protected function doSomething() { echo 'here we go' . PHP_EOL; } } class Vendor extends Base { protected function doSomething() { // do something.. // call parent (Base::doSomething()) parent::doSomething(); // do something more } } class Local extends Vendor { protected function doSomething() { // do something venture-specific // intention: call grand-parent (Base::doSomething()) parent::doSomething(); // this will call Vendor::doSomething() :( // this would work, without raising a strict error (see https://bugs.php.net/bug.php?id=42016 - not a bug!) Base::doSomething(); // a little more generic, but you need to know about inheritance level: $grandparent = get_parent_class(get_parent_class($this)); $grandparent::doSomething(); // do something more } public function api() { $this->doSomething(); } } $local = new Local; $local->api();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrZDk
function name:  (null)
number of ops:  9
compiled vars:  !0 = $local
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
   55     3        NEW                                              $2      'Local'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   56     6        INIT_METHOD_CALL                                         !0, 'api'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Class Base:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrZDk
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'here+we+go%0A'
   10     1      > RETURN                                                   null

End of function dosomething

End of class Base.

Class Vendor:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrZDk
function name:  doSomething
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'doSomething'
          1        DO_FCALL                                      0          
   23     2      > RETURN                                                   null

End of function dosomething

End of class Vendor.

Class Local:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrZDk
function name:  doSomething
number of ops:  16
compiled vars:  !0 = $grandparent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_STATIC_METHOD_CALL                                  'doSomething'
          1        DO_FCALL                                      0          
   38     2        INIT_STATIC_METHOD_CALL                                  'Base', 'doSomething'
          3        DO_FCALL                                      0          
   42     4        INIT_FCALL                                               'get_parent_class'
          5        INIT_FCALL                                               'get_parent_class'
          6        FETCH_THIS                                       ~3      
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !0, $5
   43    12        FETCH_CLASS                                   0  $7      !0
         13        INIT_STATIC_METHOD_CALL                                  $7, 'doSomething'
         14        DO_FCALL                                      0          
   47    15      > RETURN                                                   null

End of function dosomething

Function api:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrZDk
function name:  api
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   INIT_METHOD_CALL                                         'doSomething'
          1        DO_FCALL                                      0          
   52     2      > RETURN                                                   null

End of function api

End of class Local.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.71 ms | 1392 KiB | 17 Q