本文整理汇总了PHP中ReflectionProperty::getvalue方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::getvalue方法的具体用法?PHP ReflectionProperty::getvalue怎么用?PHP ReflectionProperty::getvalue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionProperty
的用法示例。
在下文中一共展示了ReflectionProperty::getvalue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetData
public function testSetData()
{
$page = new Page(new Request());
$page->setData('place', 'Norway');
$page->setData(['city' => 'Oslo', 'height' => 12]);
$ref_data = new \ReflectionProperty($page, '_data');
$ref_data->setAccessible(true);
$expected = ['place' => 'Norway', 'city' => 'Oslo', 'height' => 12];
$result = $ref_data->getvalue($page);
$this->assertEquals($expected, $result);
}
示例2: reflectProperty
/**
* Reflects a property and provides resolution callable
*
* @access private
* @return void
*/
private function reflectProperty()
{
list($class, $property) = explode('::', $this->value);
$this->class = ltrim($class, '\\');
$this->property = ltrim($property, '\\$');
$this->isProperty = TRUE;
try {
$reflection = new \ReflectionProperty($this->class, $this->property);
if (!$reflection->isPublic()) {
$reflection->setAccessible(TRUE);
}
if ($reflection->isStatic()) {
$this->call = function () use($reflection) {
return $reflection->getValue();
};
} else {
$this->needsObject = TRUE;
$this->call = function ($object) use($reflection) {
return $reflection->getvalue($object);
};
}
} catch (\ReflectionException $e) {
throw new InvalidTestException(sprintf('Cannot assert or reject undefined property "%s" on class "%s"', $this->property, $this->class));
}
}