for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SmartWeb\ModuleTesting\Util;
use ReflectionClass;
use ReflectionException;
/**
* Trait AccessesHiddenMethods
*
* @package SmartWeb\ModuleTesting\Util
*/
trait AccessesHiddenMethods
{
* @param object $object
* @param string $method
* @param mixed[] ...$parameters
* @return mixed
* @throws ReflectionException
private function invokeMethod($object, string $method, ...$parameters)
$reflection = new ReflectionClass(get_class($object));
$method = $reflection->getMethod($method);
$method->setAccessible(true);
return $method->invokeArgs($object, $parameters);
}
* @param string $property
private function getProperty($object, string $property)
$property = $reflection->getProperty($property);
$property->setAccessible(true);
return $property->getValue($object);