PHP Класс Kahlan\Jit\Interceptor

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_add string Method name for adding a set of PSR-0 directories.
$_addPsr4 string Method name for adding a set of PSR-4 directories.
$_cachePath string Cache path. If false the caching is not enable.
$_exclude array Namespaces/classes which must not be patched.
$_findFile string Method name for finding files on original autoloader.
$_getPrefixes string Method name for adding a set of PSR-0 directories.
$_getPrefixesPsr4 string Method name for adding a set of PSR-4 directories.
$_include array Allowed namespaces/classes for being patched (if empty, mean all is allowed).
$_interceptor array Overrided loader reference.
$_loadClass string Method name for loading a class.
$_originalLoader array The patched loader reference.
$_patchers object The patchers container.
$_watched integer Additionnal watched files.
$_watchedTimestamp integer Most recent modification timestamps of the watched files.

Открытые методы

Метод Описание
__call ( $method, $params ) : mixed Delegates call to original autoloader
__construct ( array $options = [] ) Constructs
allowed ( string $class ) : boolean Checks if a class is allowed to be patched.
cache ( string $file, string $content, $timestamp = null ) : string Cache helper.
cachePath ( ) : string Returns the cache path.
cached ( string $file ) : string | boolean Gets a cached file path.
clearCache ( ) Clear the cache.
composer ( ) : mixed Look for the composer autoloader.
findFile ( string $class ) : string | false Finds the path to the file where the class is defined.
findPath ( string $namespace, boolean $forceDir = false ) : string | null Returns the path of a namespace or fully namespaced class name.
getPrefixes ( ) : array Returns both PSR-0 & PSR-4 prefixes and related paths.
instance ( ) : object | null Returns the interceptor autoloader instance.
load ( $interceptor = null ) : boolean Loads an interceptor autoloader.
loadClass ( string $class ) : boolean | null Loads the given class or interface.
loadFile ( $filepath ) : boolean Loads a file.
loadFiles ( $files ) Manualy load files.
loader ( ) : array Returns the interceptor autoload function.
originalInstance ( ) : array Returns the patched autoloader instance.
originalLoader ( ) : array Returns the patched autoload function.
patch ( array $options = [] ) Patch the autoloader to be intercepted by the current autoloader.
patchable ( string $class ) : boolean Checks if a class can be patched or not.
patchers ( ) : mixed Returns the patchers container.
refreshWatched ( ) Refresh watched file timestamps
unpatch ( ) Restore the original autoloader behavior.
unwatch ( $files ) Unwatch a watched file
watch ( $files ) Sets some file to watch.
watched ( ) : The Returns watched files

Защищенные методы

Метод Описание
_path ( string $path, boolean $forceDir ) : string | null Build full path according to a root path.

Описание методов

__call() публичный Метод

Delegates call to original autoloader
public __call ( $method, $params ) : mixed
$method The method name.
$params The parameters
Результат mixed

__construct() публичный Метод

Constructs
public __construct ( array $options = [] )
$options array Options for the constructor.

_path() защищенный Метод

Build full path according to a root path.
protected _path ( string $path, boolean $forceDir ) : string | null
$path string A root path.
$forceDir boolean Only consider directories paths.
Результат string | null Returns the found path or `null` if not path is found.

allowed() публичный Метод

Checks if a class is allowed to be patched.
public allowed ( string $class ) : boolean
$class string The name of the class to check.
Результат boolean Returns `true` if the class is allowed to be patched, `false` otherwise.

cache() публичный Метод

Cache helper.
public cache ( string $file, string $content, $timestamp = null ) : string
$file string The source file path.
$content string The patched content to cache.
Результат string The patched file path or the cache path if called with no params.

cachePath() публичный Метод

Returns the cache path.
public cachePath ( ) : string
Результат string

cached() публичный Метод

Gets a cached file path.
public cached ( string $file ) : string | boolean
$file string The source file path.
Результат string | boolean The cached file path or `false` if the cached file is not valid or is not cached.

clearCache() публичный Метод

Clear the cache.
public clearCache ( )

composer() публичный статический Метод

Look for the composer autoloader.
public static composer ( ) : mixed
Результат mixed The founded composer autolaoder or `null` if not found.

findFile() публичный Метод

Finds the path to the file where the class is defined.
public findFile ( string $class ) : string | false
$class string The name of the class
Результат string | false The path if found, false otherwise

findPath() публичный Метод

Returns the path of a namespace or fully namespaced class name.
public findPath ( string $namespace, boolean $forceDir = false ) : string | null
$namespace string A namespace.
$forceDir boolean Only consider directories paths.
Результат string | null Returns the found path or `null` if not path is found.

getPrefixes() публичный Метод

Returns both PSR-0 & PSR-4 prefixes and related paths.
public getPrefixes ( ) : array
Результат array

instance() публичный статический Метод

Returns the interceptor autoloader instance.
public static instance ( ) : object | null
Результат object | null

load() публичный статический Метод

Loads an interceptor autoloader.
public static load ( $interceptor = null ) : boolean
Результат boolean Returns `true` on success, `false` otherwise.

loadClass() публичный Метод

Loads the given class or interface.
public loadClass ( string $class ) : boolean | null
$class string The name of the class.
Результат boolean | null Returns `true` if loaded, `null` otherwise.

loadFile() публичный Метод

Loads a file.
public loadFile ( $filepath ) : boolean
Результат boolean Returns `true` if loaded, null otherwise.

loadFiles() публичный Метод

Manualy load files.
public loadFiles ( $files )

loader() публичный Метод

Returns the interceptor autoload function.
public loader ( ) : array
Результат array

originalInstance() публичный Метод

Returns the patched autoloader instance.
public originalInstance ( ) : array
Результат array

originalLoader() публичный Метод

Returns the patched autoload function.
public originalLoader ( ) : array
Результат array

patch() публичный статический Метод

Patch the autoloader to be intercepted by the current autoloader.
public static patch ( array $options = [] )
$options array Options for the interceptor autoloader.

patchable() публичный Метод

Checks if a class can be patched or not.
public patchable ( string $class ) : boolean
$class string The name of the class to check.
Результат boolean Returns `true` if the class need to be patched, `false` otherwise.

patchers() публичный Метод

Returns the patchers container.
public patchers ( ) : mixed
Результат mixed

refreshWatched() публичный Метод

Refresh watched file timestamps
public refreshWatched ( )

unpatch() публичный статический Метод

Restore the original autoloader behavior.
public static unpatch ( )

unwatch() публичный Метод

Unwatch a watched file
public unwatch ( $files )
$files The array of file paths to unwatch.

watch() публичный Метод

When a watched file is modified, any cached file are invalidated.
public watch ( $files )
$files The array of file paths to watch.

watched() публичный Метод

Returns watched files
public watched ( ) : The
Результат The array of wateched file paths.

Описание свойств

$_add защищенное свойство

Method name for adding a set of PSR-0 directories.
protected string $_add
Результат string

$_addPsr4 защищенное свойство

Method name for adding a set of PSR-4 directories.
protected string $_addPsr4
Результат string

$_cachePath защищенное свойство

Cache path. If false the caching is not enable.
protected string $_cachePath
Результат string

$_exclude защищенное свойство

Namespaces/classes which must not be patched.
protected array $_exclude
Результат array

$_findFile защищенное свойство

Method name for finding files on original autoloader.
protected string $_findFile
Результат string

$_getPrefixes защищенное свойство

Method name for adding a set of PSR-0 directories.
protected string $_getPrefixes
Результат string

$_getPrefixesPsr4 защищенное свойство

Method name for adding a set of PSR-4 directories.
protected string $_getPrefixesPsr4
Результат string

$_include защищенное свойство

Allowed namespaces/classes for being patched (if empty, mean all is allowed).
protected array $_include
Результат array

$_interceptor защищенное статическое свойство

Overrided loader reference.
protected static array $_interceptor
Результат array

$_loadClass защищенное свойство

Method name for loading a class.
protected string $_loadClass
Результат string

$_originalLoader защищенное свойство

The patched loader reference.
protected array $_originalLoader
Результат array

$_patchers защищенное свойство

The patchers container.
protected object $_patchers
Результат object

$_watched защищенное свойство

Additionnal watched files.
protected int $_watched
Результат integer

$_watchedTimestamp защищенное свойство

Most recent modification timestamps of the watched files.
protected int $_watchedTimestamp
Результат integer