本文整理汇总了PHP中ReflectionProperty::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::getValue方法的具体用法?PHP ReflectionProperty::getValue怎么用?PHP ReflectionProperty::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionProperty
的用法示例。
在下文中一共展示了ReflectionProperty::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($class, $property)
{
$property = new ReflectionProperty($class, $property);
list($description, $tags) = Kodoc::parse($property->getDocComment());
$this->description = $description;
if ($modifiers = $property->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if (isset($tags['var'])) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
$this->type = $matches[1];
if (isset($matches[2])) {
$this->description = Markdown($matches[2]);
}
}
}
$this->property = $property;
// Show the value of static properties, but only if they are public or we are php 5.3 or higher and can force them to be accessible
if ($property->isStatic() and ($property->isPublic() or version_compare(PHP_VERSION, '5.3', '>='))) {
// Force the property to be accessible
if (version_compare(PHP_VERSION, '5.3', '>=')) {
$property->setAccessible(TRUE);
}
// Don't debug the entire object, just say what kind of object it is
if (is_object($property->getValue($class))) {
$this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
} else {
$this->value = Kohana::debug($property->getValue($class));
}
}
}
示例2: __construct
public function __construct($class, $property, $default = null)
{
$property = new \ReflectionProperty($class, $property);
list($description, $tags) = $this->userguide->parse($property->getDocComment());
$this->description = $description;
if ($modifiers = $property->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', \Reflection::getModifierNames($modifiers)) . '</small> ';
}
if (isset($tags['var'])) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/s', $tags['var'][0], $matches)) {
$this->type = $matches[1];
if (isset($matches[2])) {
$this->description = $this->markdown->transform($matches[2]);
}
}
}
$this->property = $property;
// Show the value of static properties, but only if they are public or we are php 5.3 or
// higher and can force them to be accessible
if ($property->isStatic()) {
$property->setAccessible(true);
// Don't debug the entire object, just say what kind of object it is
if (is_object($property->getValue($class))) {
$this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
} else {
$this->value = Debug::vars($property->getValue($class));
}
}
// Store the defult property
$this->default = Debug::vars($default);
}
示例3: reflectProperty
function reflectProperty($class, $property)
{
$propInfo = new ReflectionProperty($class, $property);
echo "**********************************\n";
echo "Reflecting on property {$class}::{$property}\n\n";
echo "__toString():\n";
var_dump($propInfo->__toString());
echo "export():\n";
var_dump(ReflectionProperty::export($class, $property, true));
echo "export():\n";
var_dump(ReflectionProperty::export($class, $property, false));
echo "getName():\n";
var_dump($propInfo->getName());
echo "isPublic():\n";
var_dump($propInfo->isPublic());
echo "isPrivate():\n";
var_dump($propInfo->isPrivate());
echo "isProtected():\n";
var_dump($propInfo->isProtected());
echo "isStatic():\n";
var_dump($propInfo->isStatic());
$instance = new $class();
if ($propInfo->isPublic()) {
echo "getValue():\n";
var_dump($propInfo->getValue($instance));
$propInfo->setValue($instance, "NewValue");
echo "getValue() after a setValue():\n";
var_dump($propInfo->getValue($instance));
}
echo "\n**********************************\n";
}
示例4: testCanReturnItemsToStock
/**
* @param bool $canReturnToStock
* @param bool $manageStock
* @param bool $result
* @dataProvider canReturnItemsToStockDataProvider
*/
public function testCanReturnItemsToStock($canReturnToStock, $manageStock, $result)
{
$productId = 7;
$property = new \ReflectionProperty($this->items, '_canReturnToStock');
$property->setAccessible(true);
$this->assertNull($property->getValue($this->items));
$this->stockConfiguration->expects($this->once())->method('canSubtractQty')->will($this->returnValue($canReturnToStock));
if ($canReturnToStock) {
$orderItem = $this->getMock('Magento\\Sales\\Model\\Order\\Item', ['getProductId', '__wakeup', 'getStore'], [], '', false);
$store = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false);
$store->expects($this->once())->method('getWebsiteId')->will($this->returnValue(10));
$orderItem->expects($this->any())->method('getStore')->will($this->returnValue($store));
$orderItem->expects($this->once())->method('getProductId')->will($this->returnValue($productId));
$creditMemoItem = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo\\Item', ['setCanReturnToStock', 'getOrderItem', '__wakeup'], [], '', false);
$creditMemo = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', [], [], '', false);
$creditMemo->expects($this->once())->method('getAllItems')->will($this->returnValue([$creditMemoItem]));
$creditMemoItem->expects($this->any())->method('getOrderItem')->will($this->returnValue($orderItem));
$this->stockItemMock->expects($this->once())->method('getManageStock')->will($this->returnValue($manageStock));
$creditMemoItem->expects($this->once())->method('setCanReturnToStock')->with($this->equalTo($manageStock))->will($this->returnSelf());
$order = $this->getMock('Magento\\Sales\\Model\\Order', ['setCanReturnToStock', '__wakeup'], [], '', false);
$order->expects($this->once())->method('setCanReturnToStock')->with($this->equalTo($manageStock))->will($this->returnSelf());
$creditMemo->expects($this->once())->method('getOrder')->will($this->returnValue($order));
$this->registryMock->expects($this->any())->method('registry')->with('current_creditmemo')->will($this->returnValue($creditMemo));
}
$this->assertSame($result, $this->items->canReturnItemsToStock());
$this->assertSame($result, $property->getValue($this->items));
// lazy load test
$this->assertSame($result, $this->items->canReturnItemsToStock());
}
示例5: extractValueInField
/**
* @param $entity
* @return \ActiveLAMP\Taxonomy\Entity\PluralVocabularyField|ArrayCollection
*/
public function extractValueInField($entity)
{
$this->property->setAccessible(true);
$field = $this->property->getValue($entity);
$this->property->setAccessible(false);
return $field;
}
示例6: testDuplicate
/**
* Method to test duplicate().
*
* @param string $label
* @param string $icon
* @param string $id
* @param string $prefix
* @param string $task
*
* @covers \Windwalker\Bootstrap\Dropdown::duplicate
* @dataProvider duplicateProvider
*/
public function testDuplicate($label, $icon, $id, $prefix, $task)
{
// Clean dropDownList property
$this->refDropDownList->setValue(array());
Dropdown::duplicate($id, $prefix);
$this->assertEquals(array('<li>' . '<a href = "javascript://" onclick="listItemTask(\'cb' . $id . '\', \'' . $task . '\')">' . ($icon ? '<span class="icon-' . $icon . '"></span> ' : '') . $label . '</a>' . '</li>'), $this->refDropDownList->getValue());
}
示例7: __get
public function __get($key)
{
$property = new \ReflectionProperty($this->class, $key);
if (!$property->isPublic()) {
$property->setAccessible(true);
}
return $property->isStatic() ? $property->getValue() : $property->getValue($this->object);
}
示例8: setUp
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
parent::setUp();
$this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.2) Gecko/2008092313 Ubuntu/8.04 (hardy) Firefox/3.0.2 FirePHP/0.1.2";
$this->Log_FirePHP = new Log_FirePHPTable("Test");
$this->unique_base = $this->prop_unique_base->getValue($this->Log_FirePHP);
}
示例9: testAutoFilter
/**
* @covers ::autoFilter
*/
public function testAutoFilter()
{
$property = new \ReflectionProperty(get_class($this->container), 'autoFilter');
$property->setAccessible(true);
$this->assertFalse($property->getValue($this->container));
$this->container->autoFilter();
$this->assertTrue($property->getValue($this->container));
}
示例10: __construct
/**
* Constructor
* @param \PHP_CodeSniffer_File $phpcsFile
*/
public function __construct(PHP_CodeSniffer_File $phpcsFile)
{
$this->phpcsFile = $phpcsFile;
$this->reflection = new ReflectionProperty($this->phpcsFile, 'ruleset');
$this->reflection->setAccessible(true);
$this->current = $this->reflection->getValue($this->phpcsFile);
$this->backup = $this->current;
}
示例11: getKeys
/**
* @static
*
* @param FormBuilderInterface $formBuilder
*
* @return array
*/
private static function getKeys(FormBuilderInterface $formBuilder)
{
if (!self::$reflection) {
self::$reflection = new \ReflectionProperty(get_class($formBuilder), 'children');
self::$reflection->setAccessible(true);
}
return array_keys(self::$reflection->getValue($formBuilder));
}
示例12: getWriter
/**
* @return Writer
*/
protected function getWriter()
{
if (null == $this->refField) {
$this->refField = new \ReflectionProperty(get_parent_class($this), 'writer');
$this->refField->setAccessible(true);
}
return $this->refField->getValue($this);
}
示例13: getValue
public function getValue($entity)
{
$value = null;
if ($this->property) {
$value = $this->property->getValue($entity);
}
return $value;
}
示例14: getProperty
private function getProperty($classOrObject, $property)
{
$property = new \ReflectionProperty(is_object($classOrObject) ? get_class($classOrObject) : $classOrObject, $property);
if (!$property->isPublic()) {
$property->setAccessible(true);
}
return $property->isStatic() ? $property->getValue($classOrObject) : $property->getValue();
}
示例15: testSetInvert
/**
* Тест установки флага инверсии.
* @covers \Epay\Sign::setInvert()
*/
public function testSetInvert()
{
$reflection = new \ReflectionProperty($this->sign, 'invertResult');
$reflection->setAccessible(true);
$this->sign->setInvert(true);
$this->assertTrue($reflection->getValue($this->sign));
$this->sign->setInvert(false);
$this->assertFalse($reflection->getValue($this->sign));
}