当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionProperty::getValue方法代码示例

本文整理汇总了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));
         }
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:31,代码来源:property.php

示例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);
 }
开发者ID:braf,项目名称:phalcana-userguide,代码行数:31,代码来源:DocProperty.php

示例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";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ReflectionProperty_basic1.php

示例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());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:ItemsTest.php

示例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;
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:11,代码来源:Vocabulary.php

示例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());
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:19,代码来源:DropdownTest.php

示例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);
 }
开发者ID:ptrofimov,项目名称:xpmock,代码行数:8,代码来源:Reflection.php

示例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);
 }
开发者ID:jasny,项目名称:Q,代码行数:11,代码来源:FirePHPTableTest.php

示例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));
 }
开发者ID:fuelphp,项目名称:display,代码行数:11,代码来源:ContainerTest.php

示例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;
 }
开发者ID:gamegos,项目名称:php-code-sniffer,代码行数:12,代码来源:RulesetHelper.php

示例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));
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:15,代码来源:FormBuilderIterator.php

示例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);
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:Visitor.php

示例13: getValue

 public function getValue($entity)
 {
     $value = null;
     if ($this->property) {
         $value = $this->property->getValue($entity);
     }
     return $value;
 }
开发者ID:20steps,项目名称:autotables-bundle,代码行数:8,代码来源:PropertyColumnDescriptor.php

示例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();
 }
开发者ID:ptrofimov,项目名称:xpmock,代码行数:8,代码来源:TestCaseTraitTest.php

示例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));
 }
开发者ID:iborodikhin,项目名称:kazkom-epay,代码行数:13,代码来源:SignTest.php


注:本文中的ReflectionProperty::getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。