grifix / reflection
This package is abandoned and no longer maintained.
No replacement package was suggested.
Wrapper for the ReflectionObject
1.0.1
2022-07-23 06:05 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
composer install grifix/reflection
Usage
final class Car
{
public function __construct(public string $producer, public Engine $engine)
{
}
}
final class Engine
{
public function __construct(public int $volume)
{
}
}
$car = new Car('Mercedes', new Engine(5));
$reflection = new \Grifix\Reflection\ReflectionObject($car);
$reflection->getPropertyValue('producer'); //Mercedes
$reflection->getPropertyValue('engine.volume'); //5
$reflection->setPropertyValue('producer', 'Volvo');
$reflection->setPropertyValue('engine.volume', 10);
$reflection->getObject(); //Car
$reflection->getWrapped(); //\ReflectionObject