略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 简介

2024-12-30

简介

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 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)

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 Componere\Patch exists, and can be reverted explicitly.

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

Casting:

Componere\ casting functions can cast among user defined compatible types; Where compatible means Type is sub or super to the type of object.

Componere\cast(Type $type, $object): Type
Componere\cast_by_ref(Type $type, $object): Type
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/intro.componere.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3