3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = -2
filename:       /in/j6Ghb
function name:  (null)
number of ops:  14
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                                                 
   5     3        NOP                                                      
  17     4        NOP                                                      
         5        NOP                                                      
  33     6        NOP                                                      
         7        NOP                                                      
  93     8        NEW                                              $7      :0
         9        DO_FCALL                                      0          
        10        ASSIGN                                                   !0, $7
  94    11        INIT_METHOD_CALL                                         !0, 'api'
        12        DO_FCALL                                      0          
        13      > RETURN                                                   1

Class Base:
Function dosomething:
Finding entry points
Branch analysis from position: 0
Jump found. 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
Jump found. Position 1 = -2
filename:       /in/j6Ghb
function name:  doSomething
number of ops:  7
compiled vars:  !0 = $something
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  24     0  E >   FETCH_CLASS                                 514  :1      
         1        INIT_STATIC_METHOD_CALL                                  $1, 'doSomething'
         2        DO_FCALL                                      0  $2      
         3        ASSIGN                                                   !0, $2
  26     4        ASSIGN_CONCAT                                 0          !0, 'bbbbbbbbbbb'
  28     5      > RETURN                                                   !0
  30     6*     > RETURN                                                   null

End of function dosomething

End of class Vendor.

Class Local:
Function dosomething:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/j6Ghb
function name:  doSomething
number of ops:  29
compiled vars:  !0 = $grandparent, !1 = $this, !2 = $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        SEND_VAR                                                 !1
         3        DO_ICALL                                         $3      
         4        SEND_VAR                                                 $3
         5        DO_ICALL                                         $4      
         6        ASSIGN                                                   !0, $4
  42     7        FETCH_CLASS                                 512  :6      !0
         8        INIT_STATIC_METHOD_CALL                                  $6, 'doSomething'
         9        DO_FCALL                                      0  $7      
        10        ASSIGN                                                   !2, $7
  44    11        ASSIGN_CONCAT                                 0          !2, 'cccccccccccc'
  46    12      > RETURN                                                   !2
  70    13*       FETCH_CLASS                                 514  :10     
        14*       INIT_STATIC_METHOD_CALL                                  $10, '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*       SEND_VAR                                                 !1
        21*       DO_ICALL                                         $13     
        22*       SEND_VAR                                                 $13
        23*       DO_ICALL                                         $14     
        24*       ASSIGN                                                   !0, $14
  79    25*       FETCH_CLASS                                 512  :16     !0
        26*       INIT_STATIC_METHOD_CALL                                  $16, 'doSomething'
        27*       DO_FCALL                                      0          
  84    28*     > RETURN                                                   null

End of function dosomething

Function api:
Finding entry points
Branch analysis from position: 0
Jump found. 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 7.2.0