Componere

目录

简介

This final abstract represents a class entry, and should not be used by the programmer.

类摘要

Componere\Abstract\Definition

final abstract class Componere\Abstract\Definition {

/* 方法 */

public Definition addInterface ( string $interface )

public Definition addMethod ( string $name , \Componere\Method $method )

public Definition addTrait ( string $trait )

public \ReflectionClass getReflector ( void )

}

Componere\Abstract\Definition::addInterface

Add Interface

说明

public Definition Componere\Abstract\Definition::addInterface ( string $interface )

Shall implement the given interface on the current definition

参数

interface
The case insensitive name of an interface

返回值

The current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Componere\Abstract\Definition::addMethod

Add Method

说明

public Definition Componere\Abstract\Definition::addMethod ( string $name , \Componere\Method $method )

Shall create or override a method on the current definition.

参数

name
The case insensitive name for method

method
\Componere\Method not previously added to another Definition

返回值

The current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Warning

Shall throw RuntimeException if Method was added to another Definition

Componere\Abstract\Definition::addTrait

Add Trait

说明

public Definition Componere\Abstract\Definition::addTrait ( string $trait )

Shall use the given trait for the current definition

参数

trait
The case insensitive name of a trait

返回值

The current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Componere\Abstract\Definition::getReflector

Reflection

说明

public \ReflectionClass Componere\Abstract\Definition::getReflector ( void )

Shall create or return a ReflectionClass

返回值

A ReflectionClass for the current definition (cached)

简介

The Definition class allows the programmer to build and register a type at runtime.

Should a Definition replace an existing class, the existing class will be restored when the Definition is destroyed.

类摘要

Componere\Definition

final class Componere\Definition extends Componere\Abstract\Definition {

/* Constructors */

public __construct ( string $name )

public __construct ( string $name , string $parent )

public __construct ( string $name , array $interfaces )

public __construct ( string $name , string $parent , array $interfaces )

/* 方法 */

public Definition addConstant ( string $name , \Componere\Value $value )

public Definition addProperty ( string $name , \Componere\Value $value )

public void register ( void )

public bool isRegistered ( void )

public \Closure getClosure ( string $name )

public array getClosures ( void )

/* 继承的方法 */

public Definition Componere\Abstract\Definition::addInterface ( string $interface )

public Definition Componere\Abstract\Definition::addMethod ( string $name , \Componere\Method $method )

public Definition Componere\Abstract\Definition::addTrait ( string $trait )

public \ReflectionClass Componere\Abstract\Definition::getReflector ( void )

}

Componere\Definition::__construct

Definition Construction

说明

public Componere\Definition::__construct ( string $name )

public Componere\Definition::__construct ( string $name , string $parent )

public Componere\Definition::__construct ( string $name , array $interfaces )

public Componere\Definition::__construct ( string $name , string $parent , array $interfaces )

参数

name
A case insensitive class name

parent
A case insensitive class name

interfaces
An array of case insensitive class names

Exceptions

Warning

Shall throw InvalidArgumentException if an attempt is made to replace an internal class

Warning

Shall throw InvalidArgumentException if an attempt is made to replace an interface

Warning

Shall throw InvalidArgumentException if an attempt is made to replace a trait

Warning

Shall throw RuntimeException if a class in interfaces cannot be found

Warning

Shall throw RuntimeException if an class in interfaces is not an interface

Componere\Definition::addConstant

Add Constant

说明

public Definition Componere\Definition::addConstant ( string $name , \Componere\Value $value )

Shall declare a class constant on the current Definition

参数

name
The case sensitive name for the constant

value
The Value for the constant, must not be undefined or static

返回值

The current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Warning

Shall throw RuntimeException if name is already declared as a constant

Warning

Shall throw RuntimeException if value is static

Warning

Shall throw RuntimeException if value is undefined

Componere\Definition::addProperty

Add Property

说明

public Definition Componere\Definition::addProperty ( string $name , \Componere\Value $value )

Shall declare a class property on the current Definition

参数

name
The case sensitive name for the property

value
The default Value for the property

返回值

The current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Warning

Shall throw RuntimeException if name is already declared as a property

Componere\Definition::register

Registration

说明

public void Componere\Definition::register ( void )

Shall register the current Definition

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Componere\Definition::isRegistered

State Detection

说明

public bool Componere\Definition::isRegistered ( void )

Shall detect the registration state of this Definition

返回值

Shall return true if this Definition is registered

Componere\Definition::getClosure

Get Closure

说明

public \Closure Componere\Definition::getClosure ( string $name )

Shall return a Closure for the method specified by name

参数

name
The case insensitive name of the method

返回值

A Closure bound to the correct scope

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

Warning

Shall throw RuntimeException if name could not be found

Componere\Definition::getClosures

Get Closures

说明

public array Componere\Definition::getClosures ( void )

Shall return an array of Closures

返回值

Shall return all methods as an array of Closure objects bound to the correct scope

Exceptions

Warning

Shall throw RuntimeException if Definition was registered

简介

The Patch class allows the programmer to change the type of an instance at runtime without registering a new Definition

When a Patch is destroyed it is reverted, so that instances that were patched during the lifetime of the Patch are restored to their formal type.

类摘要

Componere\Patch

final class Componere\Patch extends Componere\Abstract\Definition {

/* Constructors */

public __construct ( object $instance )

public __construct ( object $instance , array $interfaces )

/* 方法 */

public void apply ( void )

public void revert ( void )

public bool isApplied ( void )

public Patch derive ( object $instance )

public \Closure getClosure ( string $name )

public array getClosures ( void )

/* 继承的方法 */

public Definition Componere\Abstract\Definition::addInterface ( string $interface )

public Definition Componere\Abstract\Definition::addMethod ( string $name , \Componere\Method $method )

public Definition Componere\Abstract\Definition::addTrait ( string $trait )

public \ReflectionClass Componere\Abstract\Definition::getReflector ( void )

}

Componere\Patch::__construct

Patch Construction

说明

public Componere\Patch::__construct ( object $instance )

public Componere\Patch::__construct ( object $instance , array $interfaces )

参数

instance
The target for this Patch

interfaces
A case insensitive array of class names

Exceptions

Warning

Shall throw RuntimeException if a class in interfaces cannot be found

Warning

Shall throw RuntimeException if an class in interfaces is not an interface

Componere\Patch::apply

Application

说明

public void Componere\Patch::apply ( void )

Shall apply the current patch

Componere\Patch::revert

Reversal

说明

public void Componere\Patch::revert ( void )

Shall revert the current patch

Componere\Patch::isApplied

State Detection

说明

public bool Componere\Patch::isApplied ( void )

Componere\Patch::derive

Patch Derivation

说明

public Patch Componere\Patch::derive ( object $instance )

Shall derive a Patch for the given instance

参数

instance
The target for the derived Patch

返回值

Patch for instance derived from the current Patch

Exceptions

Warning

Shall throw InvalidArgumentException if instance is not compatible

Componere\Patch::getClosure

Get Closure

说明

public \Closure Componere\Patch::getClosure ( string $name )

Shall return a Closure for the method specified by name

参数

name
The case insensitive name of the method

返回值

A Closure bound to the correct scope and object

Exceptions

Warning

Shall throw RuntimeException if name could not be found

Componere\Patch::getClosures

Get Closures

说明

public array Componere\Patch::getClosures ( void )

Shall return an array of Closures

返回值

Shall return all methods as an array of Closure objects bound to the correct scope and object

简介

A Method represents a function with modifiable accessibility flags

类摘要

Componere\Method

final class Componere\Method {

/* Constructor */

public __construct ( \Closure $closure )

/* 方法 */

public Method setPrivate ( void )

public Method setProtected ( void )

public Method setStatic ( void )

public \ReflectionMethod getReflector ( void )

}

Componere\Method::__construct

Method Construction

说明

public Componere\Method::__construct ( \Closure $closure )

参数

closure

Componere\Method::setPrivate

Accessibility Modification

说明

public Method Componere\Method::setPrivate ( void )

返回值

The current Method

Exceptions

Warning

Shall throw RuntimeException if access level was previously set

Componere\Method::setProtected

Accessibility Modification

说明

public Method Componere\Method::setProtected ( void )

返回值

The current Method

Exceptions

Warning

Shall throw RuntimeException if access level was previously set

Componere\Method::setStatic

Accessibility Modification

说明

public Method Componere\Method::setStatic ( void )

返回值

The current Method

Componere\Method::getReflector

Reflection

说明

public \ReflectionMethod Componere\Method::getReflector ( void )

Shall create or return a ReflectionMethod

返回值

A ReflectionMethod for the current method (cached)

简介

A Value represents a PHP variable of all types, including undefined

类摘要

Componere\Value

final class Componere\Value {

/* Constructor */

public __construct ([ $default ] )

/* 方法 */

public Value setPrivate ( void )

public Value setProtected ( void )

public Value setStatic ( void )

public bool isPrivate ( void )

public bool isProtected ( void )

public bool isStatic ( void )

public bool hasDefault ( void )

}

Componere\Value::__construct

Value Construction

说明

public Componere\Value::__construct ([ $default ] )

参数

default

Exceptions

Warning

Shall throw InvalidArgumentException if default does not have a suitable value

Componere\Value::setPrivate

Accessibility Modification

说明

public Value Componere\Value::setPrivate ( void )

返回值

The current Value

Exceptions

Warning

Shall throw RuntimeException if access level was previously set

Componere\Value::setProtected

Accessibility Modification

说明

public Value Componere\Value::setProtected ( void )

返回值

The current Value

Exceptions

Warning

Shall throw RuntimeException if access level was previously set

Componere\Value::setStatic

Accessibility Modification

说明

public Value Componere\Value::setStatic ( void )

返回值

The current Value

Componere\Value::isPrivate

Accessibility Detection

说明

public bool Componere\Value::isPrivate ( void )

Componere\Value::isProtected

Accessibility Detection

说明

public bool Componere\Value::isProtected ( void )

Componere\Value::isStatic

Accessibility Detection

说明

public bool Componere\Value::isStatic ( void )

Componere\Value::hasDefault

Value Interaction

说明

public bool Componere\Value::hasDefault ( void )