Documentation

Autoload
in package

Table of Contents

$composerAutoloader  : ClassLoader
The composer autoloader.
$loadedClasses  : array<string, string>
A mapping of file names to class names.
$loadedFiles  : array<string, string>
A mapping of class names to file names.
$searchPaths  : array<string|int, string>
A list of additional directories to search during autoloading.
addSearchPath()  : void
Adds a directory to search during autoloading.
determineLoadedClass()  : string
Determine which class was loaded based on the before and after lists of loaded classes.
getLoadedClasses()  : array<string, string>
Gets the mapping of file names to class names.
getLoadedClassName()  : string
Gets the class name for the given file path.
getLoadedFileName()  : string
Gets the file path for the given class name.
getLoadedFiles()  : array<string, string>
Gets the mapping of class names to file names.
getSearchPaths()  : array<string|int, mixed>
Retrieve the namespaces and paths registered by external standards.
load()  : bool
Loads a class.
loadFile()  : string
Includes a file and tracks what class or interface was loaded as a result.

Properties

$composerAutoloader

The composer autoloader.

private static ClassLoader $composerAutoloader = null

$loadedClasses

A mapping of file names to class names.

private static array<string, string> $loadedClasses = []

$loadedFiles

A mapping of class names to file names.

private static array<string, string> $loadedFiles = []

$searchPaths

A list of additional directories to search during autoloading.

private static array<string|int, string> $searchPaths = []

This is typically a list of coding standard directories.

Methods

addSearchPath()

Adds a directory to search during autoloading.

public static addSearchPath(string $path[, string $nsPrefix = '' ]) : void
Parameters
$path : string

The path to the directory to search.

$nsPrefix : string = ''

The namespace prefix used by files under this path.

Return values
void

determineLoadedClass()

Determine which class was loaded based on the before and after lists of loaded classes.

public static determineLoadedClass(array<string|int, mixed> $classesBeforeLoad, array<string|int, mixed> $classesAfterLoad) : string
Parameters
$classesBeforeLoad : array<string|int, mixed>

The classes/interfaces/traits before the file was included.

$classesAfterLoad : array<string|int, mixed>

The classes/interfaces/traits after the file was included.

Return values
string

The fully qualified name of the class in the loaded file.

getLoadedClasses()

Gets the mapping of file names to class names.

public static getLoadedClasses() : array<string, string>
Return values
array<string, string>

getLoadedClassName()

Gets the class name for the given file path.

public static getLoadedClassName(string $path) : string
Parameters
$path : string

The name of the file.

Tags
throws
Exception

If the file path has not been loaded.

Return values
string

getLoadedFileName()

Gets the file path for the given class name.

public static getLoadedFileName(string $class) : string
Parameters
$class : string

The name of the class.

Tags
throws
Exception

If the class name has not been loaded

Return values
string

getLoadedFiles()

Gets the mapping of class names to file names.

public static getLoadedFiles() : array<string, string>
Return values
array<string, string>

getSearchPaths()

Retrieve the namespaces and paths registered by external standards.

public static getSearchPaths() : array<string|int, mixed>
Return values
array<string|int, mixed>

load()

Loads a class.

public static load(string $class) : bool

This method only loads classes that exist in the PHP_CodeSniffer namespace. All other classes are ignored and loaded by subsequent autoloaders.

Parameters
$class : string

The name of the class to load.

Return values
bool

loadFile()

Includes a file and tracks what class or interface was loaded as a result.

public static loadFile(string $path) : string
Parameters
$path : string

The path of the file to load.

Return values
string

The fully qualified name of the class in the loaded file.

Search results