You can use ReflectionProperty::setValue to set the value on static properties as well as regular instance properties. Simply pass null in place of the instance:
<?php
class Foo {
protected static $bar = null;
public static function sayBar() {
echo self::$bar;
}
}
$r = new ReflectionProperty('Foo', 'bar');
$r->setAccessible(true);
$r->setValue(null, 'foo');
Foo::sayBar(); // "foo"
?>
ReflectionProperty::setValue
(PHP 5)
ReflectionProperty::setValue — تعیین مقدار خاصیت
Description
تعیین مقدار خاصیت.
Warning
This function is currently not documented; only its argument list is available.
Parameters
- object
-
نام شی.
- value
-
نام مقدار.
Return Values
No value is returned.
me at ircmaxell dot om ¶
1 year ago
