【发布时间】:2018-06-11 09:16:52
【问题描述】:
我需要更改方法中的静态变量。代码如下所示:
function get_something()
{
static $cache = array();
if (!$cache) {
$cache = $this->compute_cache();
}
return $cache;
}
我可以获得 value 的副本。
$reflection = new ReflectionMethod($object, 'get_something');
$vars = $reflection->getStaticVariables();
有没有办法改变方法中的值?
附言
我无法更改该方法的代码。
【问题讨论】:
-
不,这是不可能的。