gollumsf/reflection-property-test
最新稳定版本:v2.0.0
Composer 安装命令:
composer require gollumsf/reflection-property-test
包简介
Add trait for reflection data and call
关键字:
README 文档
README
Add trait for reflection data and call
Requirements
- PHP >= 8.2
Install:
composer require --dev gollumsf/reflection-property-test
Usage:
use GollumSF\ReflectionPropertyTest\ReflectionPropertyTrait; class MyPrivate { private int $dataPrivate = 10; private function functionPrivate(int $value): int { return 11 + $value; } } class MyExtend extends MyPrivate { } class MyTest extends TestCase { use ReflectionPropertyTrait; public function testMyFunction(): void { $obj = new MyPrivate(); $this->assertEquals($this->reflectionGetValue($obj, 'dataPrivate'), 10); $this->reflectionSetValue($obj, 'dataPrivate', 20); $this->assertEquals($this->reflectionGetValue($obj, 'dataPrivate'), 20); $this->assertEquals($this->reflectionCallMethod($obj, 'functionPrivate', [19]), 30); $obj2 = new MyExtend(); $this->assertEquals($this->reflectionGetValue($obj2, 'dataPrivate', MyPrivate::class), 10); $this->reflectionSetValue($obj2, 'dataPrivate', 20, MyPrivate::class); $this->assertEquals($this->reflectionGetValue($obj2, 'dataPrivate', MyPrivate::class), 20); $this->assertEquals($this->reflectionCallMethod($obj2, 'functionPrivate', [19], MyPrivate::class), 30); } }
统计信息
- 总下载量: 3.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-21