tasoft / value-injector
v1.8.0
2023-02-07 20:41 UTC
Requires
- php: ^7|^8
Requires (Dev)
- phpunit/phpunit: ^6|^9
This package is auto-updated.
Last update: 2024-09-07 23:49:33 UTC
README
值注入对象是一个代理,允许您获取、设置或调用另一个对象的非可访问属性。
安装
$ composer require tasoft/value-injector
工作原理
<?php use TASoft\Util\ValueInjector; class PrivateClass { private $value; public function getValue() { return $this->value; } } $myObject = new PrivateClass(); echo $myObject->value; // Will fail echo $myObject->getValue(); // Works // But if you want to set the value, use my value injector: $vi = new ValueInjector($myObject); $vi->value = 23; echo $myObject->getValue(); // 23