zloynick/joole-reflector
Composer 安装命令:
composer require zloynick/joole-reflector
包简介
README 文档
README
Joole Reflector is used to work with the properties of objects, their changes and merges.
Getting Started
Download it with composer:
composer require zloynick/joole-reflector
Usage
Init your reflector class:
...
use joole\reflector\Reflector;
...
Build reflection object:
...
$reflectedClass = $reflector->buildFromObject($yourClass);
//OR
$reflectedClass = $reflector->buildFromObject(
YourClass::class,// class as string
[$constructorParams1, $constructorParams2],// Using for class constructor
);
...
Change private/protected properties:
...
$reflectedClass->getProperty('exampleProperty')->setValue($value);
// Notice: $value's type must be instance of property type
// or null if property nullable. "exampleProperty" is a property of
// your class, that had reflected.
...
Properties merging:
...
$reflector->merge($class, [
'id' => $id,
'value' => $value,
]);
// OR
$reflector->merge($class, $classFrom, [
'id' => $id,
'value',//if exists at $classFrom
]);
...
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2022-02-25