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


PHP ReflectionProperty::setValue方法代码示例

本文整理汇总了PHP中ReflectionProperty::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::setValue方法的具体用法?PHP ReflectionProperty::setValue怎么用?PHP ReflectionProperty::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionProperty的用法示例。


在下文中一共展示了ReflectionProperty::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: doInjection

 protected function doInjection($instance, $className)
 {
     $propertiesAnnotations = $this->annotationManager->getPropertiesAnnotations($className);
     foreach ($propertiesAnnotations as $propertyName => $annotations) {
         if (isset($annotations['Inject'])) {
             /** @var \A7\Annotations\Inject $inject */
             $inject = $annotations['Inject'];
             $reflectionProperty = new \ReflectionProperty($instance, $propertyName);
             $reflectionProperty->setAccessible(true);
             if (isset($annotations['var'])) {
                 $inject->setVar($annotations['var']);
             }
             $inject->isInjectObject();
             if ($inject->isInjectObject()) {
                 $reflectionProperty->setValue($instance, $this->a7->get($inject->getName()));
             } else {
                 $name = $inject->getName();
                 if (isset($name) && isset($this->parameters[$name])) {
                     $reflectionProperty->setValue($instance, $this->parameters[$name]);
                 }
             }
         }
     }
     return $instance;
 }
开发者ID:ArmineKhachatryan,项目名称:A7,代码行数:25,代码来源:DependencyInjection.php

示例3: __set

 /**
  * __set.
  *
  * Overloading method to set any $key property to $this->class or if not static,
  * to $this->object.
  *
  * @param  $key
  * @param  $value
  * @return $this
  */
 public function __set($key, $value)
 {
     $property = new \ReflectionProperty($this->class, $key);
     $property->setAccessible(true);
     $property->isStatic() ? $property->setValue($value) : $property->setValue($this->object, $value);
     return $this;
 }
开发者ID:nark3d,项目名称:PhalueObjects,代码行数:17,代码来源:AbstractReflection.php

示例4: doMockResponse

 public function doMockResponse($set_minimal, $body_id, $set_title)
 {
     $restoreInstance = PMA\libraries\Response::getInstance();
     // mock footer
     $mockFooter = $this->getMockBuilder('PMA\\libraries\\Footer')->disableOriginalConstructor()->setMethods(array('setMinimal'))->getMock();
     $mockFooter->expects($this->exactly($set_minimal))->method('setMinimal')->with();
     // mock header
     $mockHeader = $this->getMockBuilder('PMA\\libraries\\Header')->disableOriginalConstructor()->setMethods(array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML'))->getMock();
     $mockHeader->expects($this->exactly($body_id))->method('setBodyId')->with('loginform');
     $mockHeader->expects($this->exactly($set_title))->method('setTitle')->with('Access denied!');
     $mockHeader->expects($this->exactly($set_title))->method('disableMenuAndConsole')->with();
     // set mocked headers and footers
     $mockResponse = $this->getMockBuilder('PMA\\libraries\\Response')->disableOriginalConstructor()->setMethods(array('getHeader', 'getFooter', 'addHTML', 'header', 'headersSent'))->getMock();
     $mockResponse->expects($this->exactly($set_title))->method('getFooter')->with()->will($this->returnValue($mockFooter));
     $mockResponse->expects($this->exactly($set_title))->method('getHeader')->with()->will($this->returnValue($mockHeader));
     $mockResponse->expects($this->any())->method('headersSent')->with()->will($this->returnValue(false));
     $mockResponse->expects($this->exactly($set_title * 6))->method('addHTML')->with();
     $attrInstance = new ReflectionProperty('PMA\\libraries\\Response', '_instance');
     $attrInstance->setAccessible(true);
     $attrInstance->setValue($mockResponse);
     $headers = array_slice(func_get_args(), 3);
     $header_method = $mockResponse->expects($this->exactly(count($headers)))->method('header');
     call_user_func_array(array($header_method, 'withConsecutive'), $headers);
     try {
         $this->assertFalse($this->object->auth());
     } finally {
         $attrInstance->setValue($restoreInstance);
     }
 }
开发者ID:rclakmal,项目名称:phpmyadmin,代码行数:29,代码来源:AuthenticationHttpTest.php

示例5: testStringifyFail

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testStringifyFail()
 {
     $ip = TestDataGenerator::ipString();
     $range = new Range(new IP($ip), new IP($ip));
     $mockConverter = $this->getMock('Bankiru\\IPTools\\Interfaces\\RangeConverterInterface');
     $mockConverter->expects($this->once())->method('stringify')->with($this->equalTo($range))->willThrowException(new \InvalidArgumentException('INVALID RANGE'));
     $this->refProp->setValue(null, array($mockConverter));
     $this->instance->stringify($range);
     $this->fail('parse should fail on invalid input');
 }
开发者ID:bankiru,项目名称:ip-tools,代码行数:13,代码来源:RangeFactoryTest.php

示例6: testRemoveApiKey

 public function testRemoveApiKey()
 {
     $user = User::create('Ma27', '123456', 'Ma27@sententiaregum.dev', new PhpPasswordHasher());
     $p = new \ReflectionProperty($user, 'apiKey');
     $p->setAccessible(true);
     $this->assertEmpty($user->getApiKey());
     $p->setValue($user, 'key');
     $this->assertNotEmpty($user->getApiKey());
     $p->setValue($user, null);
     $this->assertEmpty($user->getApiKey());
 }
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:11,代码来源:UserTest.php

示例7: testStreamIncludeWithRealFile

 public function testStreamIncludeWithRealFile()
 {
     $property = new ReflectionProperty('rex_stream', 'useRealFiles');
     $property->setAccessible(true);
     $property->setValue(true);
     $content = 'foo <?php echo "bar";';
     $streamUrl = rex_stream::factory('test-stream/2', $content);
     ob_start();
     require $streamUrl;
     $result = ob_get_clean();
     $this->assertEquals('foo bar', $result);
     $property->setValue(null);
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:13,代码来源:stream_test.php

示例8: testGetOptions

 public function testGetOptions()
 {
     $this->getModel($this->validatorMock);
     $appStateProperty = new \ReflectionProperty('Magento\\Framework\\Session\\Config', 'options');
     $appStateProperty->setAccessible(true);
     $original = $appStateProperty->getValue($this->config);
     $valueForTest = ['test' => 'test2'];
     $appStateProperty->setValue($this->config, $valueForTest);
     $this->assertEquals($valueForTest, $this->config->getOptions());
     $this->assertEquals($valueForTest, $this->config->toArray());
     $appStateProperty->setValue($this->config, $original);
     $this->assertEquals($original, $this->config->getOptions());
     $this->assertEquals($original, $this->config->toArray());
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:14,代码来源:ConfigTest.php

示例9: setAttribute

 /**
  * Set protected/private attribute of object
  *
  * @param object &$object       Object containing attribute
  * @param string $attributeName Attribute name to change
  * @param string $value         Value to set attribute to
  *
  * @return null
  */
 public function setAttribute(&$object, $attributeName, $value)
 {
     $class = is_object($object) ? get_class($object) : $object;
     $reflection = new \ReflectionProperty($class, $attributeName);
     $reflection->setAccessible(true);
     $reflection->setValue($object, $value);
 }
开发者ID:bossjones,项目名称:puphpet,代码行数:16,代码来源:BaseTest.php

示例10: __construct

 /**
  * Constructs the exception.
  * @link http://php.net/manual/en/errorexception.construct.php
  * @param $message [optional]
  * @param $code [optional]
  * @param $severity [optional]
  * @param $filename [optional]
  * @param $lineno [optional]
  * @param $previous [optional]
  */
 public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, \Exception $previous = null)
 {
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
     if (function_exists('xdebug_get_function_stack')) {
         $trace = array_slice(array_reverse(xdebug_get_function_stack()), 3, -1);
         foreach ($trace as &$frame) {
             if (!isset($frame['function'])) {
                 $frame['function'] = 'unknown';
             }
             // XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695
             if (!isset($frame['type']) || $frame['type'] === 'static') {
                 $frame['type'] = '::';
             } elseif ($frame['type'] === 'dynamic') {
                 $frame['type'] = '->';
             }
             // XDebug has a different key name
             if (isset($frame['params']) && !isset($frame['args'])) {
                 $frame['args'] = $frame['params'];
             }
         }
         $ref = new \ReflectionProperty('Exception', 'trace');
         $ref->setAccessible(true);
         $ref->setValue($this, $trace);
     }
 }
开发者ID:sanggabee,项目名称:hellomedia-yii-basic,代码行数:35,代码来源:ErrorException.php

示例11: testValidateSetEntityAttributeValuesWithoutResource

 public function testValidateSetEntityAttributeValuesWithoutResource()
 {
     $product = $this->getMock('Magento\\Framework\\Model\\AbstractModel', ['someMethod', 'getResource', 'load'], [], '', false);
     $this->_condition->setAttribute('someAttribute');
     $product->setAtribute('attribute');
     $product->setId(12);
     $this->_configProperty->setValue($this->_condition, $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false));
     $this->_entityAttributeValuesProperty->setValue($this->_condition, $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false));
     $attribute = new \Magento\Framework\DataObject();
     $attribute->setBackendType('multiselect');
     $newResource = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product', ['getAttribute'], [], '', false);
     $newResource->expects($this->any())->method('getAttribute')->with('someAttribute')->will($this->returnValue($attribute));
     $newResource->_config = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $product->expects($this->atLeastOnce())->method('getResource')->willReturn($newResource);
     $this->_entityAttributeValuesProperty->setValue($this->_condition, [1 => [''], 2 => ['option1,option2,option3'], 3 => ['option1,option2,option3']]);
     $this->assertFalse($this->_condition->validate($product));
     $attribute = new \Magento\Framework\DataObject();
     $attribute->setBackendType(null);
     $attribute->setFrontendInput('multiselect');
     $newResource = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product', ['getAttribute'], [], '', false);
     $newResource->expects($this->any())->method('getAttribute')->with('someAttribute')->will($this->returnValue($attribute));
     $newResource->_config = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $product->setResource($newResource);
     $product->setId(1);
     $product->setData('someAttribute', 'value');
     $this->assertFalse($this->_condition->validate($product));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:AbstractProductTest.php

示例12: enableOpenSSL

 private function enableOpenSSL()
 {
     $ref = new \ReflectionProperty('Bitpay\\Util\\SecureRandom', 'hasOpenSSL');
     $ref->setAccessible(true);
     $ref->setValue(null);
     $ref->setAccessible(false);
 }
开发者ID:bitpay,项目名称:php-client,代码行数:7,代码来源:SecureRandomTest.php

示例13: setProperty

 /**
  * @param object $object
  * @param string $property
  * @param mixed $value
  * @return $this
  */
 protected function setProperty($object, $property, $value)
 {
     $reflection = new \ReflectionProperty(get_class($object), $property);
     $reflection->setAccessible(true);
     $reflection->setValue($object, $value);
     return $this;
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:AbstractTest.php

示例14: testSearchPercentile

 /**
  * @covers ArticleQualityService::searchPercentile
  */
 public function testSearchPercentile()
 {
     $mock = $this->getMockBuilder("\\ArticleQualityService")->disableOriginalConstructor()->setMethods(['__construct'])->getMock();
     $refl = new \ReflectionMethod($mock, 'searchPercentile');
     $refl->setAccessible(true);
     $prop = new \ReflectionProperty($mock, 'percentiles');
     $prop->setAccessible(true);
     $prop->setValue($mock, [1 => 0.1, 2 => 0.2, 3 => 0.3, 4 => 0.4]);
     $this->assertEquals(2, $refl->invoke($mock, 0.25));
     $this->assertEquals(4, $refl->invoke($mock, 0.5));
     $this->assertEquals(1, $refl->invoke($mock, 0.05));
     $prop->setValue($mock, [-1 => -0.1, 0 => 0.05, 1 => 0.8]);
     $this->assertEquals(-1, $refl->invoke($mock, -2));
     $this->assertEquals(0, $refl->invoke($mock, 0.4));
     $this->assertEquals(1, $refl->invoke($mock, 1));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ArticleQualityServiceTest.php

示例15: updateRevision

 protected function updateRevision(AbstractRevision $revision, AbstractRevision $previous = null)
 {
     $this->contentLengthProperty->setValue($revision, $this->calcContentLength($revision));
     if ($previous !== null) {
         $this->previousContentLengthProperty->setValue($revision, $this->calcContentLength($previous));
     }
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:7,代码来源:FlowUpdateRevisionContentLength.php


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