grifix/reflection

This package is abandoned and no longer maintained. No replacement package was suggested.

Wrapper for the ReflectionObject

Maintainers

Details

gitlab.com/grifix/reflection

1.0.1 2022-07-23 06:05 UTC

This package is auto-updated.

Last update: 2023-07-26 07:07:03 UTC


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