PHP Class Kahlan\Jit\Patcher\Monkey

Show file Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Property Type Description
$_blacklist array Ignoring the following statements which are not valid function or class names.
$_counter integer Counter for building unique variable name.
$_depth integer Nested function depth level.
$_prefix string Prefix to use for custom variable name.
$_regex string The regex.
$_uses array Uses for the parsed node's namespace.
$_variables array Variables for the parsed node.

Public Methods

Method Description
__construct ( $config = [] ) The constructor.
blacklisted ( string $name = null ) : boolean Check if a function is part of the blacklisted ones.
findFile ( object $loader, string $class, string $file ) : string The JIT find file patcher.
patchable ( string $class ) : boolean The JIT patchable checker.
process ( object $node, string $path = null ) : object The JIT patcher.

Protected Methods

Method Description
_addClosingParenthesis ( $pos, integer $index, array $parent ) : boolean Add a closing parenthesis
_flushVariables ( array $node ) Flush stored variables in the passed node.
_monkeyPatch ( object $node, array $parent, integer $index ) Monkey patch a node body.
_processTree ( $parent ) Helper for Monkey::process().

Method Details

__construct() public method

The constructor.
public __construct ( $config = [] )

_addClosingParenthesis() protected method

Add a closing parenthesis
protected _addClosingParenthesis ( $pos, integer $index, array $parent ) : boolean
$index integer The index of node in parent children.
$parent array The parent array.
return boolean Returns `true` if succeed, `false` otherwise.

_flushVariables() protected method

Flush stored variables in the passed node.
protected _flushVariables ( array $node )
$node array The node to store variables in.

_monkeyPatch() protected method

Monkey patch a node body.
protected _monkeyPatch ( object $node, array $parent, integer $index )
$node object The node to monkey patch.
$parent array The parent array.
$index integer The index of node in parent children.

_processTree() protected method

Helper for Monkey::process().
protected _processTree ( $parent )

blacklisted() public static method

Check if a function is part of the blacklisted ones.
public static blacklisted ( string $name = null ) : boolean
$name string A function name.
return boolean

findFile() public method

The JIT find file patcher.
public findFile ( object $loader, string $class, string $file ) : string
$loader object The autloader instance.
$class string The fully-namespaced class name.
$file string The correponding finded file path.
return string The patched file path.

patchable() public method

The JIT patchable checker.
public patchable ( string $class ) : boolean
$class string The fully-namespaced class name to check.
return boolean

process() public method

The JIT patcher.
public process ( object $node, string $path = null ) : object
$node object The node instance to patch.
$path string The file path of the source code.
return object The patched node.

Property Details

$_blacklist protected static property

Ignoring the following statements which are not valid function or class names.
protected static array $_blacklist
return array

$_counter protected property

Counter for building unique variable name.
protected int $_counter
return integer

$_depth protected property

Nested function depth level.
protected int $_depth
return integer

$_prefix protected property

Prefix to use for custom variable name.
protected string $_prefix
return string

$_regex protected property

The regex.
protected string $_regex
return string

$_uses protected property

Uses for the parsed node's namespace.
protected array $_uses
return array

$_variables protected property

Variables for the parsed node.
protected array $_variables
return array