yep/reflection
最新稳定版本:v2.1.0
Composer 安装命令:
composer require yep/reflection
包简介
PHP class reflection enhancements
关键字:
README 文档
README
PHP class reflection enhancements (For PHP7+)
Packagist
Reflection is available on Packagist.org, just add the dependency to your composer.json.
{
"require" : {
"yep/reflection": "^2.0"
}
}
or run Composer command:
php composer.phar require yep/reflection
What do Yep/Reflection?
"Test subject" and example code
<?php class SomeClass { private $someProperty; protected function someMethod($someArgument) { return $someArgument; } public function getSomeProperty() { return $this->someProperty; } public function setSomeProperty($someProperty) { $this->someProperty = $someProperty; } } class SomeClass2 extends SomeClass { } $someClass = new SomeClass(); $reflection = \Yep\Reflection\ReflectionClass::from($class = $someClass);
You can simply call the protected or private method
<?php $someClass = new SomeClass(); echo $reflection->invokeMethod($method = 'someMethod', $arguments = ['foo']); // 'foo'
You can simply set value to the protected or private property
<?php $someClass = new SomeClass(); $reflection->setPropertyValue($property = 'someProperty', $value = 'foo'); echo $someClass->getSomeProperty(); // 'foo'
You can simply get value from the protected or private property
<?php $someClass = new SomeClass(); $someClass->setSomeProperty('foo'); echo $reflection->getPropertyValue($property = 'someProperty'); // 'foo';
Wanna access parent or parent's private property?
<?php $someClass = new SomeClass2(); $someClass->setSomeProperty('foo'); echo $reflection->getParent()->getPropertyValue($property = 'someProperty'); // 'foo';
统计信息
- 总下载量: 101.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-12-30