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) { echo "Calling virtual method $name...\n"; /* if $name is an alias, replace it */ if (isset($this->aliases[$name])) { $name = $this->aliases[$name]; echo "That's an alias for $name...\n"; } /* 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" )); } private function actualMethod() { echo "Inside the actual method\n"; } } $sub = new Sub; $sub->alias();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RQD43
function name:  (null)
number of ops:  6
compiled vars:  !0 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   NEW                                              $1      'Sub'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   47     3        INIT_METHOD_CALL                                         !0, 'alias'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Super:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RQD43
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 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/RQD43
function name:  __call
number of ops:  32
compiled vars:  !0 = $name, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ROPE_INIT                                     3  ~3      'Calling+virtual+method+'
          3        ROPE_ADD                                      1  ~3      ~3, !0
          4        ROPE_END                                      2  ~2      ~3, '...%0A'
          5        ECHO                                                     ~2
   16     6        FETCH_OBJ_IS                                     ~5      'aliases'
          7        ISSET_ISEMPTY_DIM_OBJ                         0          ~5, !0
          8      > JMPZ                                                     ~6, ->16
   17     9    >   FETCH_OBJ_R                                      ~7      'aliases'
         10        FETCH_DIM_R                                      ~8      ~7, !0
         11        ASSIGN                                                   !0, ~8
   18    12        ROPE_INIT                                     3  ~11     'That%27s+an+alias+for+'
         13        ROPE_ADD                                      1  ~11     ~11, !0
         14        ROPE_END                                      2  ~10     ~11, '...%0A'
         15        ECHO                                                     ~10
   22    16    >   INIT_FCALL                                               'method_exists'
         17        FETCH_THIS                                       ~13     
         18        SEND_VAL                                                 ~13
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $14     
         21        BOOL_NOT                                         ~15     $14
         22      > JMPZ                                                     ~15, ->27
   23    23    >   NEW                                              $16     'Exception'
         24        SEND_VAL_EX                                              'The+specified+method+or+method+alias+is+undefined+in+the+current+context'
         25        DO_FCALL                                      0          
         26      > THROW                                         0          $16
   27    27    >   INIT_METHOD_CALL                                         !0
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0  $18     
         30      > RETURN                                                   $18
   28    31*     > 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/RQD43
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_STATIC_METHOD_CALL                                  
   36     1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
   38     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/RQD43
function name:  actualMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ECHO                                                     'Inside+the+actual+method%0A'
   42     1      > RETURN                                                   null

End of function actualmethod

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

End of function __call

End of class Sub.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.11 ms | 1404 KiB | 15 Q