WinCacheClassLoader
in package
WinCacheClassLoader implements a wrapping autoloader cached in WinCache.
It expects an object implementing a findFile method to find the file. This allow using it as a wrapper around the other loaders of the component (the ClassLoader for instance) but also around any other autoloaders following this convention (the Composer one for instance).
// with a Symfony autoloader
$loader = new ClassLoader();
$loader->addPrefix('Symfony\Component', __DIR__.'/component');
$loader->addPrefix('Symfony', __DIR__.'/framework');
// or with a Composer autoloader
use Composer\Autoload\ClassLoader;
$loader = new ClassLoader();
$loader->add('Symfony\Component', __DIR__.'/component');
$loader->add('Symfony', __DIR__.'/framework');
$cachedLoader = new WinCacheClassLoader('my_prefix', $loader);
// activate the cached autoloader
$cachedLoader->register();
// eventually deactivate the non-cached loader if it was registered previously
// to be sure to use the cached one.
$loader->unregister();
Tags
Table of Contents
- $decorated : object
- A class loader object that implements the findFile() method.
- $prefix : mixed
- __call() : mixed
- Passes through all unknown calls onto the decorated object.
- __construct() : mixed
- findFile() : string|null
- Finds a file by class name while caching lookups to WinCache.
- loadClass() : bool|null
- Loads the given class or interface.
- register() : mixed
- Registers this instance as an autoloader.
- unregister() : mixed
- Unregisters this instance as an autoloader.
Properties
$decorated
A class loader object that implements the findFile() method.
protected
object
$decorated
$prefix
private
mixed
$prefix
Methods
__call()
Passes through all unknown calls onto the decorated object.
public
__call(mixed $method, mixed $args) : mixed
Parameters
- $method : mixed
- $args : mixed
Return values
mixed —__construct()
public
__construct(string $prefix, object $decorated) : mixed
Parameters
- $prefix : string
-
The WinCache namespace prefix to use
- $decorated : object
-
A class loader object that implements the findFile() method
Tags
Return values
mixed —findFile()
Finds a file by class name while caching lookups to WinCache.
public
findFile(string $class) : string|null
Parameters
- $class : string
-
A class name to resolve to file
Return values
string|null —loadClass()
Loads the given class or interface.
public
loadClass(string $class) : bool|null
Parameters
- $class : string
-
The name of the class
Return values
bool|null —True, if loaded
register()
Registers this instance as an autoloader.
public
register([bool $prepend = false ]) : mixed
Parameters
- $prepend : bool = false
-
Whether to prepend the autoloader or not
Return values
mixed —unregister()
Unregisters this instance as an autoloader.
public
unregister() : mixed