setAccessible(true); $value = $property->getValue($object); $property->setAccessible(false); return $value; } public function setPrivateProperty($object, $propertyName, $value) { $property = new \ReflectionProperty(get_class($object), $propertyName); $property->setAccessible(true); $property->setValue($object, $value); $property->setAccessible(false); } public function invokePrivateMethod($object, $methodName, $parameters) { $method = new \ReflectionMethod(get_class($object), $methodName); $method->setAccessible(true); $result = $method->invokeArgs($object, $parameters); $method->setAccessible(false); return $result; } }