ClassMapAutoloader
in package
implements
SplAutoloader
Class-map autoloader
Utilizes class-map files to lookup classfile locations.
Table of Contents
Interfaces
- SplAutoloader
- Defines an interface for classes that may register with the spl_autoload registry
Properties
- $map : array<string|int, mixed>
- Class name/filename map
- $mapsLoaded : array<string|int, mixed>
- Registry of map files that have already been loaded
Methods
- __construct() : mixed
- Constructor
- autoload() : mixed
- Autoload a class
- getAutoloadMap() : array<string|int, mixed>
- Retrieve current autoload map
- realPharPath() : string
- Resolve the real_path() to a file within a phar.
- register() : void
- Register the autoloader with spl_autoload registry
- registerAutoloadMap() : ClassMapAutoloader
- Register an autoload map
- registerAutoloadMaps() : ClassMapAutoloader
- Register many autoload maps at once
- setOptions() : ClassMapAutoloader
- Configure the autoloader
- loadMapFromFile() : ClassMapAutoloader|mixed
- Load a map from a file
Properties
$map
Class name/filename map
protected
array<string|int, mixed>
$map
= []
$mapsLoaded
Registry of map files that have already been loaded
protected
array<string|int, mixed>
$mapsLoaded
= []
Methods
__construct()
Constructor
public
__construct([null|array<string|int, mixed>|Traversable $options = null ]) : mixed
Create a new instance, and optionally configure the autoloader.
Parameters
- $options : null|array<string|int, mixed>|Traversable = null
autoload()
Autoload a class
public
autoload(mixed $class) : mixed
Parameters
- $class : mixed
Return values
mixed —False [if unable to load $class] get_class($class) [if $class is successfully loaded]
getAutoloadMap()
Retrieve current autoload map
public
getAutoloadMap() : array<string|int, mixed>
Return values
array<string|int, mixed>realPharPath()
Resolve the real_path() to a file within a phar.
public
static realPharPath(string $path) : string
Parameters
- $path : string
Tags
Return values
stringregister()
Register the autoloader with spl_autoload registry
public
register() : void
registerAutoloadMap()
Register an autoload map
public
registerAutoloadMap(string|array<string|int, mixed> $map) : ClassMapAutoloader
An autoload map may be either an associative array, or a file returning an associative array.
An autoload map should be an associative array containing classname/file pairs.
Parameters
- $map : string|array<string|int, mixed>
Tags
Return values
ClassMapAutoloaderregisterAutoloadMaps()
Register many autoload maps at once
public
registerAutoloadMaps(array<string|int, mixed> $locations) : ClassMapAutoloader
Parameters
- $locations : array<string|int, mixed>
Tags
Return values
ClassMapAutoloadersetOptions()
Configure the autoloader
public
setOptions(array<string|int, mixed>|Traversable $options) : ClassMapAutoloader
Parameters
- $options : array<string|int, mixed>|Traversable
Return values
ClassMapAutoloaderloadMapFromFile()
Load a map from a file
protected
loadMapFromFile(string $location) : ClassMapAutoloader|mixed
If the map has been previously loaded, returns the current instance; otherwise, returns whatever was returned by calling include() on the location.
Parameters
- $location : string