PHP Class Kahlan\Jit\Interceptor

Afficher le fichier Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Свойство Type Description
$_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.

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
_path ( string $path, boolean $forceDir ) : string | null Build full path according to a root path.

Method Details

__call() public méthode

Delegates call to original autoloader
public __call ( $method, $params ) : mixed
$method The method name.
$params The parameters
Résultat mixed

__construct() public méthode

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

_path() protected méthode

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.
Résultat string | null Returns the found path or `null` if not path is found.

allowed() public méthode

Checks if a class is allowed to be patched.
public allowed ( string $class ) : boolean
$class string The name of the class to check.
Résultat boolean Returns `true` if the class is allowed to be patched, `false` otherwise.

cache() public méthode

Cache helper.
public cache ( string $file, string $content, $timestamp = null ) : string
$file string The source file path.
$content string The patched content to cache.
Résultat string The patched file path or the cache path if called with no params.

cachePath() public méthode

Returns the cache path.
public cachePath ( ) : string
Résultat string

cached() public méthode

Gets a cached file path.
public cached ( string $file ) : string | boolean
$file string The source file path.
Résultat string | boolean The cached file path or `false` if the cached file is not valid or is not cached.

clearCache() public méthode

Clear the cache.
public clearCache ( )

composer() public static méthode

Look for the composer autoloader.
public static composer ( ) : mixed
Résultat mixed The founded composer autolaoder or `null` if not found.

findFile() public méthode

Finds the path to the file where the class is defined.
public findFile ( string $class ) : string | false
$class string The name of the class
Résultat string | false The path if found, false otherwise

findPath() public méthode

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.
Résultat string | null Returns the found path or `null` if not path is found.

getPrefixes() public méthode

Returns both PSR-0 & PSR-4 prefixes and related paths.
public getPrefixes ( ) : array
Résultat array

instance() public static méthode

Returns the interceptor autoloader instance.
public static instance ( ) : object | null
Résultat object | null

load() public static méthode

Loads an interceptor autoloader.
public static load ( $interceptor = null ) : boolean
Résultat boolean Returns `true` on success, `false` otherwise.

loadClass() public méthode

Loads the given class or interface.
public loadClass ( string $class ) : boolean | null
$class string The name of the class.
Résultat boolean | null Returns `true` if loaded, `null` otherwise.

loadFile() public méthode

Loads a file.
public loadFile ( $filepath ) : boolean
Résultat boolean Returns `true` if loaded, null otherwise.

loadFiles() public méthode

Manualy load files.
public loadFiles ( $files )

loader() public méthode

Returns the interceptor autoload function.
public loader ( ) : array
Résultat array

originalInstance() public méthode

Returns the patched autoloader instance.
public originalInstance ( ) : array
Résultat array

originalLoader() public méthode

Returns the patched autoload function.
public originalLoader ( ) : array
Résultat array

patch() public static méthode

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

patchable() public méthode

Checks if a class can be patched or not.
public patchable ( string $class ) : boolean
$class string The name of the class to check.
Résultat boolean Returns `true` if the class need to be patched, `false` otherwise.

patchers() public méthode

Returns the patchers container.
public patchers ( ) : mixed
Résultat mixed

refreshWatched() public méthode

Refresh watched file timestamps
public refreshWatched ( )

unpatch() public static méthode

Restore the original autoloader behavior.
public static unpatch ( )

unwatch() public méthode

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

watch() public méthode

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

watched() public méthode

Returns watched files
public watched ( ) : The
Résultat The array of wateched file paths.

Property Details

$_add protected_oe property

Method name for adding a set of PSR-0 directories.
protected string $_add
Résultat string

$_addPsr4 protected_oe property

Method name for adding a set of PSR-4 directories.
protected string $_addPsr4
Résultat string

$_cachePath protected_oe property

Cache path. If false the caching is not enable.
protected string $_cachePath
Résultat string

$_exclude protected_oe property

Namespaces/classes which must not be patched.
protected array $_exclude
Résultat array

$_findFile protected_oe property

Method name for finding files on original autoloader.
protected string $_findFile
Résultat string

$_getPrefixes protected_oe property

Method name for adding a set of PSR-0 directories.
protected string $_getPrefixes
Résultat string

$_getPrefixesPsr4 protected_oe property

Method name for adding a set of PSR-4 directories.
protected string $_getPrefixesPsr4
Résultat string

$_include protected_oe property

Allowed namespaces/classes for being patched (if empty, mean all is allowed).
protected array $_include
Résultat array

$_interceptor protected_oe static_oe property

Overrided loader reference.
protected static array $_interceptor
Résultat array

$_loadClass protected_oe property

Method name for loading a class.
protected string $_loadClass
Résultat string

$_originalLoader protected_oe property

The patched loader reference.
protected array $_originalLoader
Résultat array

$_patchers protected_oe property

The patchers container.
protected object $_patchers
Résultat object

$_watched protected_oe property

Additionnal watched files.
protected int $_watched
Résultat integer

$_watchedTimestamp protected_oe property

Most recent modification timestamps of the watched files.
protected int $_watchedTimestamp
Résultat integer