3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Super { private $aliases; protected function __construct(array $aliases) { $this->aliases = $aliases; } public function __call($name, $arguments) { /* if $name is an alias, replace it */ if (isset($this->aliases[$name])) { $name = $this->aliases[$name]; } /* throw an exception if the method is undefined */ if (!method_exists($this, $name)) { throw new Exception("The specified method or method alias is undefined in the current context"); } /* finally, call the method by its actual name */ return $this->$name($arguments); } } class Sub extends Super { public function __construct() { parent::__construct(array( "alias" => "actualMethod" )); } public function actualMethod() { echo "Inside the actual method"; } } $sub = new Sub; $sub->actualMethod(); $sub->alias();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5RTa
function name:  (null)
number of ops:  8
compiled vars:  !0 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $1      'Sub'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   44     3        INIT_METHOD_CALL                                         !0, 'actualMethod'
          4        DO_FCALL                                      0          
   45     5        INIT_METHOD_CALL                                         !0, 'alias'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class Super:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5RTa
function name:  __construct
number of ops:  4
compiled vars:  !0 = $aliases
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'aliases'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/U5RTa
function name:  __call
number of ops:  24
compiled vars:  !0 = $name, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_OBJ_IS                                     ~2      'aliases'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, !0
          4      > JMPZ                                                     ~3, ->8
   15     5    >   FETCH_OBJ_R                                      ~4      'aliases'
          6        FETCH_DIM_R                                      ~5      ~4, !0
          7        ASSIGN                                                   !0, ~5
   19     8    >   INIT_FCALL                                               'method_exists'
          9        FETCH_THIS                                       ~7      
         10        SEND_VAL                                                 ~7
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
         13        BOOL_NOT                                         ~9      $8
         14      > JMPZ                                                     ~9, ->19
   20    15    >   NEW                                              $10     'Exception'
         16        SEND_VAL_EX                                              'The+specified+method+or+method+alias+is+undefined+in+the+current+context'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $10
   24    19    >   INIT_METHOD_CALL                                         !0
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $12     
         22      > RETURN                                                   $12
   25    23*     > RETURN                                                   null

End of function __call

End of class Super.

Class Sub:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5RTa
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_STATIC_METHOD_CALL                                  
   33     1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
   35     3      > RETURN                                                   null

End of function __construct

Function actualmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5RTa
function name:  actualMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ECHO                                                     'Inside+the+actual+method'
   39     1      > RETURN                                                   null

End of function actualmethod

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/U5RTa
function name:  __call
number of ops:  24
compiled vars:  !0 = $name, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_OBJ_IS                                     ~2      'aliases'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, !0
          4      > JMPZ                                                     ~3, ->8
   15     5    >   FETCH_OBJ_R                                      ~4      'aliases'
          6        FETCH_DIM_R                                      ~5      ~4, !0
          7        ASSIGN                                                   !0, ~5
   19     8    >   INIT_FCALL                                               'method_exists'
          9        FETCH_THIS                                       ~7      
         10        SEND_VAL                                                 ~7
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
         13        BOOL_NOT                                         ~9      $8
         14      > JMPZ                                                     ~9, ->19
   20    15    >   NEW                                              $10     'Exception'
         16        SEND_VAL_EX                                              'The+specified+method+or+method+alias+is+undefined+in+the+current+context'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $10
   24    19    >   INIT_METHOD_CALL                                         !0
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $12     
         22      > RETURN                                                   $12
   25    23*     > RETURN                                                   null

End of function __call

End of class Sub.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.52 ms | 1404 KiB | 15 Q