3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AliasesLoader { private $aliases = array(); /** * @param array $aliases */ public function __construct($aliases) { $this->setAliases($aliases); } public function register() { spl_autoload_register(array($this, 'load')); } public function load($class) { if ($this->hasAlias($class)) { class_alias($class, $this->getAlias($class)); } } protected function getAlias($class) { return $this->aliases[$class]; } protected function hasAlias($class) { return isset($this->aliases[$class]); } private function setAliases(array $aliases) { $this->aliases = $aliases; } } $a = new AliasesLoader(array('B' => 'A')); $a->register(); spl_autoload_register(function ($c) { var_dump('autoloading "'.$c.'"'); }); new B();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  (null)
number of ops:  14
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $1      'AliasesLoader'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   45     4        INIT_METHOD_CALL                                         !0, 'register'
          5        DO_FCALL                                      0          
   46     6        INIT_FCALL                                               'spl_autoload_register'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FC2S0g%3A46%240'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                                 
   48    10        NEW                                              $7      'B'
         11        DO_FCALL                                      0          
         12        FREE                                                     $7
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FC2S0g%3A46%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'var_dump'
          2        CONCAT                                           ~1      'autoloading+%22', !0
          3        CONCAT                                           ~2      ~1, '%22'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
          6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FC2S0g%3A46%240

Class AliasesLoader:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  __construct
number of ops:  5
compiled vars:  !0 = $aliases
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        INIT_METHOD_CALL                                         'setAliases'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   13     4      > RETURN                                                   null

End of function __construct

Function register:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  register
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'spl_autoload_register'
          1        FETCH_THIS                                       ~0      
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'load'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   18     6      > RETURN                                                   null

End of function register

Function load:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/C2S0g
function name:  load
number of ops:  13
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        INIT_METHOD_CALL                                         'hasAlias'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->12
   23     5    >   INIT_FCALL                                               'class_alias'
          6        SEND_VAR                                                 !0
          7        INIT_METHOD_CALL                                         'getAlias'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   25    12    > > RETURN                                                   null

End of function load

Function getalias:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  getAlias
number of ops:  5
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        FETCH_OBJ_R                                      ~1      'aliases'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   30     4*     > RETURN                                                   null

End of function getalias

Function hasalias:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2S0g
function name:  hasAlias
number of ops:  5
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   34     1        FETCH_OBJ_IS                                     ~1      'aliases'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   35     4*     > RETURN                                                   null

End of function hasalias

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

End of function setaliases

End of class AliasesLoader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.49 ms | 945 KiB | 20 Q