Intro/componere-Phpdoc专题
Componere (latin,\ English:\ compose) targets production environments and provides an API for composition of classes, monkey patching, and casting.
Composition:
Componere\Definition is used to define (or redefine) a class at runtime; The class can then be registered, and in the case of redefinition it replaces the original class for as long as the Componere\Definition exists.
public <span
class="methodname">Componere\Definition::__construct ( <span
class="methodparam">string $name
)
public <span
class="methodname">Componere\Definition::__construct ( <span
class="methodparam">string $name
,
string
$parent
)
public <span
class="methodname">Componere\Definition::__construct ( <span
class="methodparam">string $name
,
array
$interfaces
)
public <span
class="methodname">Componere\Definition::__construct ( <span
class="methodparam">string $name
,
string
$parent
, <span
class="type">array $interfaces
)
Patching:
Componere\Patch is used to change the class of a specific instance of an object at runtime; Upon application the patch will remain applied for as long as the <span class="classname">Componere\Patch exists, and can be reverted explicitly.
public <span
class="methodname">Componere\Patch::__construct ( <span
class="methodparam">object $instance
)
public <span
class="methodname">Componere\Patch::__construct ( <span
class="methodparam">object $instance
, array
$interfaces
)
Casting:
Componere\ casting functions can cast
among user defined compatible types; Where compatible means <span
class="classname">Type is sub or super to the type of object
.
Type <span
class="methodname">Componere\cast ( <span
class="methodparam">Type $type
,
$object
)
Type <span
class="methodname">Componere\cast_by_ref ( <span
class="methodparam">Type $type
,
$object
)