3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Autoloader { private $directory; private $prefix; private $prefixLength; /** * @param string $baseDirectory Base directory where the source files are located. */ public function __construct($baseDirectory = __DIR__) { $this->directory = $baseDirectory; $this->prefix = __NAMESPACE__ . '\\'; $this->prefixLength = strlen($this->prefix); } /** * Registers the autoloader class with the PHP SPL autoloader. * * @param boolean $prepend Prepend the autoloader on the stack instead of appending it. */ public static function register($prepend = false) { spl_autoload_register(array(new self, 'autoload'), true, $prepend); } /** * Loads a class from a file using its fully qualified name. * * @param string $className Fully qualified name of a class. */ public function autoload($className) { if (0 === strpos($className, $this->prefix)) { $parts = explode('\\', substr($className, $this->prefixLength)); $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php'; if (is_file($filepath)) { require($filepath); } } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a77Uu
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E > > RETURN                                                   1

Class Autoloader:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a77Uu
function name:  __construct
number of ops:  10
compiled vars:  !0 = $baseDirectory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      '%2Fin'
   13     1        ASSIGN_OBJ                                               'directory'
          2        OP_DATA                                                  !0
   14     3        ASSIGN_OBJ                                               'prefix'
          4        OP_DATA                                                  '%5C'
   15     5        FETCH_OBJ_R                                      ~4      'prefix'
          6        STRLEN                                           ~5      ~4
          7        ASSIGN_OBJ                                               'prefixLength'
          8        OP_DATA                                                  ~5
   16     9      > 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/a77Uu
function name:  register
number of ops:  11
compiled vars:  !0 = $prepend
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV_INIT                                        !0      <false>
   25     1        INIT_FCALL                                               'spl_autoload_register'
          2        NEW                          self                $1      
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
          5        ADD_ARRAY_ELEMENT                                ~3      'autoload'
          6        SEND_VAL                                                 ~3
          7        SEND_VAL                                                 <true>
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   26    10      > RETURN                                                   null

End of function register

Function autoload:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 32
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 32
filename:       /in/a77Uu
function name:  autoload
number of ops:  33
compiled vars:  !0 = $className, !1 = $parts, !2 = $filepath
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~3      'prefix'
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        IS_IDENTICAL                                             $4, 0
          7      > JMPZ                                                     ~5, ->32
   36     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%5C'
         10        INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !0
         12        FETCH_OBJ_R                                      ~6      'prefixLength'
         13        SEND_VAL                                                 ~6
         14        DO_ICALL                                         $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !1, $8
   37    18        FETCH_OBJ_R                                      ~10     'directory'
         19        CONCAT                                           ~11     ~10, '%2F'
         20        INIT_FCALL                                               'implode'
         21        SEND_VAL                                                 '%2F'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $12     
         24        CONCAT                                           ~13     ~11, $12
         25        CONCAT                                           ~14     ~13, '.php'
         26        ASSIGN                                                   !2, ~14
   39    27        INIT_FCALL                                               'is_file'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $16     
         30      > JMPZ                                                     $16, ->32
   40    31    >   INCLUDE_OR_EVAL                                          !2, REQUIRE
   43    32    > > RETURN                                                   null

End of function autoload

End of class Autoloader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.29 ms | 1400 KiB | 25 Q