for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LeKoala\DevToolkit\Helpers;
use ReflectionObject;
class DevUtils
{
/**
* @param object $obj
* @param string $prop
* @param mixed $val
* @return void
*/
public static function updateProp(object $obj, string $prop, $val): void
$refObject = new ReflectionObject($obj);
$refProperty = $refObject->getProperty($prop);
$refProperty->setAccessible(true);
$refProperty->setValue($obj, $val);
}
* @param callable $cb
public static function updatePropCb(object $obj, string $prop, callable $cb): void
$refProperty->setValue($obj, $cb($refProperty->getValue($obj)));
* @return mixed
public static function getProp(object $obj, string $prop)
return $refProperty->getValue($obj);