3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); class Base { protected function doSomething() { echo 'here we go' . PHP_EOL; $something = 'aaaaaa'; return $something; } } class Vendor extends Base { protected function doSomething() { // do something.. // call parent (Base::doSomething()) $something = parent::doSomething(); $something .= "bbbbbbbbbbb"; return $something; // do something more } } class Local extends Vendor { protected function doSomething() { // do something.. // call parent (Base::doSomething()) $something = parent::doSomething(); $something .= "cccccccccccc"; return $something; // do something more // 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() { $something = $this->doSomething(); echo $something; } } $local = new Local; $local->api();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Uf5Re
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                                                 
   92     3        NEW                                              $2      'Local'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   93     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/Uf5Re
function name:  doSomething
number of ops:  4
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                     'here+we+go%0A'
   12     1        ASSIGN                                                   !0, 'aaaaaa'
   13     2      > RETURN                                                   !0
   14     3*     > 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/Uf5Re
function name:  doSomething
number of ops:  6
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'doSomething'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   26     3        ASSIGN_OP                                     8          !0, 'bbbbbbbbbbb'
   28     4      > RETURN                                                   !0
   30     5*     > 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/Uf5Re
function name:  doSomething
number of ops:  21
compiled vars:  !0 = $something, !1 = $grandparent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_STATIC_METHOD_CALL                                  'doSomething'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   43     3        ASSIGN_OP                                     8          !0, 'cccccccccccc'
   45     4      > RETURN                                                   !0
   69     5*       INIT_STATIC_METHOD_CALL                                  'doSomething'
          6*       DO_FCALL                                      0          
   73     7*       INIT_STATIC_METHOD_CALL                                  'Base', 'doSomething'
          8*       DO_FCALL                                      0          
   77     9*       INIT_FCALL                                               'get_parent_class'
         10*       INIT_FCALL                                               'get_parent_class'
         11*       FETCH_THIS                                       ~7      
         12*       SEND_VAL                                                 ~7
         13*       DO_ICALL                                         $8      
         14*       SEND_VAR                                                 $8
         15*       DO_ICALL                                         $9      
         16*       ASSIGN                                                   !1, $9
   78    17*       FETCH_CLASS                                   0  $11     !1
         18*       INIT_STATIC_METHOD_CALL                                  $11, 'doSomething'
         19*       DO_FCALL                                      0          
   83    20*     > 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/Uf5Re
function name:  api
number of ops:  5
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   87     0  E >   INIT_METHOD_CALL                                         'doSomething'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   88     3        ECHO                                                     !0
   89     4      > RETURN                                                   null

End of function api

End of class Local.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.76 ms | 1400 KiB | 17 Q