HumHub Documentation (unofficial)

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

$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>

register()

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
throws
InvalidArgumentException
Return values
ClassMapAutoloader

loadMapFromFile()

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
Tags
throws
InvalidArgumentException

For nonexistent locations.

Return values
ClassMapAutoloader|mixed

        
On this page

Search results