PHP Class lithium\core\StaticObject

See also: lithium\core\Object
Show file Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_methodFilters Stores the closures that represent the method filters. They are indexed by called class.
$_parents array Keeps a cached list of each class' inheritance tree.

Public Methods

Method Description
applyFilter ( mixed $method, Closure $filter = null ) : void Apply a closure to a method of the current static object.
invokeMethod ( string $method, array $params = [] ) : mixed Calls a method on this object with the given parameters. Provides an OO wrapper for forward_static_call_array(), and improves performance by using straight method calls in most cases.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.

Protected Methods

Method Description
_filter ( string $method, array $params, Closure $callback, array $filters = [] ) : mixed Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it.
_instance ( string | object $name, array $options = [] ) : object Returns an instance of a class with given config. The name could be a key from the classes array, a fully namespaced class name, or an object. Typically this method is used in _init to create the dependencies used in the current class.
_parents ( ) : array Gets and caches an array of the parent methods of a class.
_stop ( integer | string $status ) : void Exit immediately. Primarily used for overrides during testing.

Method Details

_filter() protected static method

Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it.
See also: lithium\util\collection\Filters
protected static _filter ( string $method, array $params, Closure $callback, array $filters = [] ) : mixed
$method string The name of the method being executed.
$params array An associative array containing all the parameters passed into the method.
$callback Closure The method's implementation, wrapped in a closure.
$filters array Additional filters to apply to the method for this call only.
return mixed

_instance() protected static method

Returns an instance of a class with given config. The name could be a key from the classes array, a fully namespaced class name, or an object. Typically this method is used in _init to create the dependencies used in the current class.
protected static _instance ( string | object $name, array $options = [] ) : object
$name string | object A `classes` key or fully-namespaced class name.
$options array The configuration passed to the constructor.
return object

_parents() protected static method

Gets and caches an array of the parent methods of a class.
protected static _parents ( ) : array
return array Returns an array of parent classes for the current class.

_stop() protected static method

Exit immediately. Primarily used for overrides during testing.
protected static _stop ( integer | string $status ) : void
$status integer | string integer range 0 to 254, string printed on exit
return void

applyFilter() public static method

Apply a closure to a method of the current static object.
See also: lithium\core\StaticObject::_filter()
See also: lithium\util\collection\Filters
public static applyFilter ( mixed $method, Closure $filter = null ) : void
$method mixed The name of the method to apply the closure to. Can either be a single method name as a string, or an array of method names. Can also be false to remove all filters on the current object.
$filter Closure The closure that is used to filter the method(s), can also be false to remove all the current filters for the given method.
return void

invokeMethod() public static method

Calls a method on this object with the given parameters. Provides an OO wrapper for forward_static_call_array(), and improves performance by using straight method calls in most cases.
public static invokeMethod ( string $method, array $params = [] ) : mixed
$method string Name of the method to call.
$params array Parameter list to use when calling `$method`.
return mixed Returns the result of the method call.

respondsTo() public static method

Determines if a given method can be called.
public static respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
return boolean Returns `true` if the method can be called, `false` otherwise.

Property Details

$_methodFilters protected static property

Stores the closures that represent the method filters. They are indexed by called class.
protected static $_methodFilters

$_parents protected static property

Keeps a cached list of each class' inheritance tree.
protected static array $_parents
return array