friendica_2021-01/library/langdet/tests/PrivProxy.php

43 lines
1,004 B
PHP
Raw Normal View History

2017-10-05 11:58:18 +02:00
<?php
/**
* Helper that enables access to private and protected methods and properties.
*/
class PrivProxy
{
private $obj;
public function __construct($obj)
{
$this->obj = $obj;
}
public function __call($method, $arguments)
{
$rm = new ReflectionMethod($this->obj, $method);
$rm->setAccessible(true);
return $rm->invokeArgs($this->obj, $arguments);
}
public static function __callStatic($method, $arguments)
{
$rm = new ReflectionMethod($this->obj, $method);
$rm->setAccessible(true);
return $rm->invokeArgs($this->obj, $arguments);
}
public function __set($var, $value)
{
$rp = new ReflectionProperty($this->obj, $var);
$rp->setAccessible(true);
$rp->setValue($this->obj, $value);
}
public function __get($var)
{
$rp = new ReflectionProperty($this->obj, $var);
$rp->setAccessible(true);
return $rp->getValue($this->obj);
}
}
?>