getValue($object); } /** * @param object $object * @param string $property * @param mixed $value * * @throws \ReflectionException */ public static function setProperty(object $object, string $property, $value): void { static::getReflectionProperty($object, $property)->setValue($object, $value); } /** * @param object $object * @param string $property * * @return \ReflectionProperty * @throws \ReflectionException */ private static function getReflectionProperty(object $object, string $property): ReflectionProperty { $prop = new ReflectionProperty($object, $property); $prop->setAccessible(true); return $prop; } }