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; $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.. $grandparent = get_parent_class(get_parent_class($this)); $something = $grandparent::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/j6Ghb
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                                                 
   93     3        NEW                                              $2      'Local'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   94     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/j6Ghb
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/j6Ghb
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/j6Ghb
function name:  doSomething
number of ops:  30
compiled vars:  !0 = $grandparent, !1 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   INIT_FCALL                                               'get_parent_class'
          1        INIT_FCALL                                               'get_parent_class'
          2        FETCH_THIS                                       ~2      
          3        SEND_VAL                                                 ~2
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
   42     8        FETCH_CLASS                                   0  $6      !0
          9        INIT_STATIC_METHOD_CALL                                  $6, 'doSomething'
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !1, $7
   44    12        ASSIGN_OP                                     8          !1, 'cccccccccccc'
   46    13      > RETURN                                                   !1
   70    14*       INIT_STATIC_METHOD_CALL                                  'doSomething'
         15*       DO_FCALL                                      0          
   74    16*       INIT_STATIC_METHOD_CALL                                  'Base', 'doSomething'
         17*       DO_FCALL                                      0          
   78    18*       INIT_FCALL                                               'get_parent_class'
         19*       INIT_FCALL                                               'get_parent_class'
         20*       FETCH_THIS                                       ~12     
         21*       SEND_VAL                                                 ~12
         22*       DO_ICALL                                         $13     
         23*       SEND_VAR                                                 $13
         24*       DO_ICALL                                         $14     
         25*       ASSIGN                                                   !0, $14
   79    26*       FETCH_CLASS                                   0  $16     !0
         27*       INIT_STATIC_METHOD_CALL                                  $16, 'doSomething'
         28*       DO_FCALL                                      0          
   84    29*     > 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/j6Ghb
function name:  api
number of ops:  5
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   INIT_METHOD_CALL                                         'doSomething'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   89     3        ECHO                                                     !0
   90     4      > RETURN                                                   null

End of function api

End of class Local.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.15 ms | 1400 KiB | 17 Q