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


PHP ReflectionClass::getProperty方法代码示例

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


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

示例1: __get

 /**
  * Magic function which handles the properties accessibility.
  * @param string $propertyName The property name.
  */
 public function __get($propertyName)
 {
     switch ($propertyName) {
         case '_baseExtendableObject':
             return $this->_baseExtendableObject;
         default:
             $class = new \ReflectionClass($this);
             if ($class->hasProperty($propertyName)) {
                 $property = $class->getProperty($propertyName);
                 $property->setAccessible(true);
                 return $property->getValue($this);
             } else {
                 if ($class->hasProperty('_' . $propertyName)) {
                     $property = $class->getProperty('_' . $propertyName);
                     $property->setAccessible(true);
                     return $property->getValue($this);
                 } else {
                     $baseClass = new \ReflectionClass($_baseExtendableObject);
                     $method = $baseClass->getMethod('__get');
                     return $method->invoke($this, $propertyName);
                 }
             }
             return null;
     }
 }
开发者ID:Gnucki,项目名称:DaFramework,代码行数:29,代码来源:ExtendableObjectDecorator.php

示例2: testAddExternalField

 public function testAddExternalField()
 {
     $this->assertClassHasStaticAttribute('_fieldTable', '\\Test\\ItemExt');
     $this->assertClassHasStaticAttribute('_tableForeignKeys', '\\Test\\ItemExt');
     $itemExtReflection = new \ReflectionClass('\\Test\\ItemExt');
     $fieldsReflection = $itemExtReflection->getProperty('_fieldTable');
     $fieldsReflection->setAccessible(true);
     $this->assertTrue(is_array($fieldsReflection->getValue()));
     $this->assertCount(0, $fieldsReflection->getValue());
     $tablesReflection = $itemExtReflection->getProperty('_tableForeignKeys');
     $tablesReflection->setAccessible(true);
     $this->assertTrue(is_array($tablesReflection->getValue()));
     $this->assertCount(0, $tablesReflection->getValue());
     ItemExt::init();
     $this->assertCount(6, $fieldsReflection->getValue());
     $this->assertTrue(isset($fieldsReflection->getValue()['city_name']));
     $this->assertTrue(isset($fieldsReflection->getValue()['city_population']));
     $this->assertTrue(isset($fieldsReflection->getValue()['sku']));
     $this->assertTrue(isset($fieldsReflection->getValue()['length']));
     $this->assertTrue(isset($fieldsReflection->getValue()['width']));
     $this->assertTrue(isset($fieldsReflection->getValue()['height']));
     $this->assertCount(2, $tablesReflection->getValue());
     $this->assertTrue(isset($tablesReflection->getValue()['item_city']));
     $this->assertTrue(isset($tablesReflection->getValue()['item_properties']));
 }
开发者ID:Ekhvalov,项目名称:recordsman,代码行数:25,代码来源:TExternalFieldsTest.php

示例3: testConstruct

 /**
  * @covers ::__construct
  * @covers ::getMethod
  * @covers ::getPath
  * @covers ::getAcceptHeader
  * @covers ::getAuthorizationHeader
  * @covers ::getCookie
  * @covers ::getPost
  */
 public function testConstruct()
 {
     $cookie = new Cookie($this->configuration);
     $server = ['HTTPS' => 'https', 'HTTP_HOST' => 'www.example.com', 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => 'foo', 'REQUEST_URI' => '/'];
     $post = ['User.Email' => 'user@example.com'];
     $request = new Request($cookie, $server, $post);
     $reflector = new \ReflectionClass($request);
     $methodProperty = $reflector->getProperty('method');
     $methodProperty->setAccessible(true);
     $this->assertSame('GET', $methodProperty->getValue($request));
     $this->assertSame('GET', $request->getMethod());
     $urlProperty = $reflector->getProperty('url');
     $urlProperty->setAccessible(true);
     $this->assertSame('https://www.example.com', $urlProperty->getValue($request));
     $this->assertSame('', $request->getPath());
     $expectedHeaders = ['Accept' => 'application/json', 'Authorization' => 'foo'];
     $headersProperty = $reflector->getProperty('headers');
     $headersProperty->setAccessible(true);
     $this->assertSame($expectedHeaders, $headersProperty->getValue($request));
     $this->assertSame('application/json', $request->getAcceptHeader());
     $this->assertSame('foo', $request->getAuthorizationHeader());
     $cookieProperty = $reflector->getProperty('cookie');
     $cookieProperty->setAccessible(true);
     $this->assertSame($cookie, $cookieProperty->getValue($request));
     $this->assertSame($cookie, $request->getCookie());
     $postProperty = $reflector->getProperty('post');
     $postProperty->setAccessible(true);
     $this->assertSame($post, $postProperty->getValue($request));
     $this->assertSame($post, $request->getPost());
 }
开发者ID:zortje,项目名称:mvc,代码行数:39,代码来源:RequestTest.php

示例4: testGetThumbnailSource

 /**
  * @dataProvider getThumbnailSourceProvider
  * @covers File::getThumbnailSource
  */
 public function testGetThumbnailSource($data)
 {
     $backendMock = $this->getMockBuilder('FSFileBackend')->setConstructorArgs([['name' => 'backendMock', 'wikiId' => wfWikiID()]])->getMock();
     $repoMock = $this->getMockBuilder('FileRepo')->setConstructorArgs([['name' => 'repoMock', 'backend' => $backendMock]])->setMethods(['fileExists', 'getLocalReference'])->getMock();
     $fsFile = new FSFile('fsFilePath');
     $repoMock->expects($this->any())->method('fileExists')->will($this->returnValue(true));
     $repoMock->expects($this->any())->method('getLocalReference')->will($this->returnValue($fsFile));
     $handlerMock = $this->getMock('BitmapHandler', ['supportsBucketing']);
     $handlerMock->expects($this->any())->method('supportsBucketing')->will($this->returnValue($data['supportsBucketing']));
     $fileMock = $this->getMockBuilder('File')->setConstructorArgs(['fileMock', $repoMock])->setMethods(['getThumbnailBucket', 'getLocalRefPath', 'getHandler'])->getMockForAbstractClass();
     $fileMock->expects($this->any())->method('getThumbnailBucket')->will($this->returnValue($data['thumbnailBucket']));
     $fileMock->expects($this->any())->method('getLocalRefPath')->will($this->returnValue('localRefPath'));
     $fileMock->expects($this->any())->method('getHandler')->will($this->returnValue($handlerMock));
     $reflection = new ReflectionClass($fileMock);
     $reflection_property = $reflection->getProperty('handler');
     $reflection_property->setAccessible(true);
     $reflection_property->setValue($fileMock, $handlerMock);
     if (!is_null($data['tmpBucketedThumbCache'])) {
         $reflection_property = $reflection->getProperty('tmpBucketedThumbCache');
         $reflection_property->setAccessible(true);
         $reflection_property->setValue($fileMock, $data['tmpBucketedThumbCache']);
     }
     $result = $fileMock->getThumbnailSource(['physicalWidth' => $data['physicalWidth']]);
     $this->assertEquals($data['expectedPath'], $result['path'], $data['message']);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:FileTest.php

示例5: __construct

 /**
  * You cannot create an instance of Schema class
  * directly
  *
  * @param $model
  */
 protected function __construct($model)
 {
     $this->klass = $model;
     if (class_exists(get_class($this->klass))) {
         $reflectionClass = new \ReflectionClass(get_class($this->klass));
         /*
         | We will set the database connection name here
         */
         if (property_exists($this->klass, 'database')) {
             $reflectionProperty = $reflectionClass->getProperty('database');
             $reflectionProperty->setAccessible(true);
             $this->database = $reflectionProperty->getValue($this->klass);
         } else {
             $this->database = $this->getDefaultConnection();
         }
         /*
         | We will set the primary key of the table schema
         */
         if (property_exists($this->klass, 'primaryKey')) {
             $reflectionPropertyKey = $reflectionClass->getProperty('primaryKey');
             $reflectionPropertyKey->setAccessible(true);
             $this->primaryKey = $reflectionPropertyKey->getValue($this->klass);
         }
         /*
         | Set database connection name
         */
         $this->setDatabaseConnection($this->database);
         if (!property_exists($this->klass, 'tableName')) {
             $this->tableName = Inflector::tabilize(get_class($this->klass));
         }
     }
 }
开发者ID:sanjoydesk,项目名称:framework,代码行数:38,代码来源:Schema.php

示例6: testAnnotations

 /**
  * Testing annotations.
  *
  * @test
  */
 public function testAnnotations()
 {
     $sut = new AsDateTime();
     $reflection = new \ReflectionClass($sut);
     $comments = $reflection->getDocComment();
     $expected = preg_quote('@Annotation');
     $results = preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches);
     $this->assertEquals(1, $results);
     $expected = preg_quote('@Target({"PROPERTY"})');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     $property = $reflection->getProperty('allowNull');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var ') . '(bool|boolean)';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('min');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var \\DateTime');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     $property = $reflection->getProperty('max');
     //
     $comments = $property->getDocComment();
     $expected = preg_quote('@var \\DateTime');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
 }
开发者ID:bairwell,项目名称:hydrator,代码行数:30,代码来源:AsDateTimeTest.php

示例7: successfullyDecompressGzRawPostData

 /**
  * @test
  * @group library
  */
 public function successfullyDecompressGzRawPostData()
 {
     $compressedRequestFileDirectory = Registry::getConfig()->test->request->storage->directory . DIRECTORY_SEPARATOR . 'compressed' . DIRECTORY_SEPARATOR;
     $compressedRawBodyFile = $compressedRequestFileDirectory . 'gzCompressed.body';
     $decompressedParamFile = $compressedRequestFileDirectory . 'gzDeompressedParams.php';
     $this->assertFileExists($compressedRawBodyFile, 'Komprimierte Test-Request-Datei nicht gefunden: ' . $compressedRawBodyFile);
     $this->assertFileExists($decompressedParamFile, 'Dekomprimierte Test-Param-Variablen-Datei nicht gefunden: ' . $decompressedParamFile);
     // Dekomprimierte Werte ermitteln
     $decompressedParams = (include $decompressedParamFile);
     // Request-Objekt erzeugen
     $request = new HttpRequestCompressed();
     // Raw Post Daten setzen
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $_SERVER['HTTP_X_CMS_ENCODING'] = 'gz';
     $reflectionClass = new \ReflectionClass('Cms\\Controller\\Request\\HttpCompressed');
     $reflectionPropertyDecompressedFlag = $reflectionClass->getProperty('postDataDecompressed');
     $reflectionPropertyDecompressedFlag->setAccessible(true);
     $reflectionPropertyDecompressedFlag->setValue($request, false);
     $reflectionPropertyRawBody = $reflectionClass->getProperty('_rawBody');
     $reflectionPropertyRawBody->setAccessible(true);
     $reflectionPropertyRawBody->setValue($request, file_get_contents($compressedRawBodyFile));
     // Dekomprimieren
     $request->decompressRequest();
     // Dekomprimierung pruefen
     $jsonParams = $request->getParam(\Cms\Request\Base::REQUEST_PARAMETER);
     $this->assertInternalType('string', $jsonParams);
     $params = json_decode($jsonParams, true);
     $this->assertInternalType('array', $params);
     $this->assertSame($decompressedParams, $params);
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:34,代码来源:HttpCompressedTest.php

示例8: testGetSiteMapCollection

 /**
  *
  */
 public function testGetSiteMapCollection()
 {
     $this->assertInstanceOf('Evheniy\\SitemapXmlBundle\\Collection\\SiteMapCollection', $this->siteMapIndexEntity->getSiteMapCollection());
     $siteMapCollection = $this->reflectionClass->getProperty('siteMapCollection');
     $siteMapCollection->setAccessible(true);
     $this->assertEquals($siteMapCollection->getValue($this->siteMapIndexEntity), $this->siteMapIndexEntity->getSiteMapCollection());
 }
开发者ID:evheniy,项目名称:SitemapXmlBundle,代码行数:10,代码来源:SiteMapIndexEntityTest.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     $this->date = $date = date('YmdHi');
     $this->mock = $this->getMockBuilder('NodExportController')->disableOriginalConstructor()->getMock();
     $this->mock->method('createAllTempTables');
     $reflectionClass = new ReflectionClass('NodExportController');
     $institutionCode = $reflectionClass->getProperty('institutionCode');
     $institutionCode->setAccessible(true);
     $institutionCode->setValue($this->mock, Yii::app()->params['institution_code']);
     $exportPath = $reflectionClass->getProperty('exportPath');
     $exportPath->setAccessible(true);
     $exportPath->setValue($this->mock, realpath(dirname(__FILE__) . '/../../../') . '/runtime/nod-export/test/' . $institutionCode->getValue($this->mock) . '/' . $this->date);
     $zipName = $reflectionClass->getProperty('zipName');
     $zipName->setAccessible(true);
     $zipName->setValue($this->mock, $institutionCode->getValue($this->mock) . '_' . $this->date . '_NOD_Export.zip');
     $this->controller = $reflectionClass;
     $this->exportPath = $exportPath->getValue($this->mock);
     $this->zipName = $zipName->getValue($this->mock);
     if (!file_exists($exportPath->getValue($this->mock))) {
         mkdir($exportPath->getValue($this->mock), 0777, true);
     }
     $createAllTempTablesmethod = $this->controller->getMethod('createAllTempTables');
     $createAllTempTablesmethod->setAccessible(true);
     $createAllTempTablesmethod->invoke($this->mock);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:26,代码来源:NodExportControllerTest.php

示例10: test_parse_property_annotation

 /**
  * @test
  */
 public function test_parse_property_annotation()
 {
     $intf = new \ReflectionClass(Todo::class);
     $commentParser = new AnnotationConverterAdapter($intf);
     id:
     $annotations = $commentParser->getPropertyAnnotations($intf->getProperty('id'));
     $this->assertCount(2, $annotations);
     $this->assertInstanceOf(Column::class, $annotations[0]);
     $this->assertEquals('todo_id', $annotations[0]->name);
     $this->assertNull($annotations[0]->default);
     $this->assertCount(0, $annotations[0]->optFields);
     $this->assertInstanceOf(ColumnType::class, $annotations[1]);
     $this->assertEquals('integer', $annotations[1]->type);
     $this->assertEquals('id', $annotations[1]->name);
     todo:
     $annotations = $commentParser->getPropertyAnnotations($intf->getProperty('todo'));
     $this->assertCount(3, $annotations);
     $this->assertInstanceOf(Column::class, $annotations[0]);
     $this->assertEquals('content', $annotations[0]->name);
     $this->assertNull($annotations[0]->default);
     $this->assertCount(0, $annotations[0]->optFields);
     $this->assertInstanceOf(Alias::class, $annotations[1]);
     $this->assertEquals('content', $annotations[1]->name);
     $this->assertEquals(['text', 'memo'], $annotations[1]->alias);
     $this->assertInstanceOf(ColumnType::class, $annotations[2]);
     $this->assertEquals('string', $annotations[2]->type);
     $this->assertEquals('todo', $annotations[2]->name);
     created:
     $annotations = $commentParser->getPropertyAnnotations($intf->getProperty('created'));
     $this->assertCount(1, $annotations);
     $this->assertInstanceOf(ColumnType::class, $annotations[0]);
     $this->assertEquals(\DateTime::class, $annotations[0]->type);
     $this->assertEquals('created', $annotations[0]->name);
     hidden:
     $annotations = $commentParser->getPropertyAnnotations($intf->getProperty('hidden'));
     $this->assertCount(2, $annotations);
     $this->assertInstanceOf(Column::class, $annotations[0]);
     $this->assertNull(null, $annotations[0]->name);
     $this->assertEquals(0, $annotations[0]->default);
     $this->assertCount(0, $annotations[0]->optFields);
     $this->assertInstanceOf(ColumnType::class, $annotations[1]);
     $this->assertEquals(Hidden::class, $annotations[1]->type);
     $this->assertEquals('hidden', $annotations[1]->name);
     creator:
     $annotations = $commentParser->getPropertyAnnotations($intf->getProperty('creator'));
     $this->assertCount(4, $annotations);
     $this->assertInstanceOf(Column::class, $annotations[0]);
     $this->assertEquals('creator_id', $annotations[0]->name);
     $this->assertNull($annotations[0]->default);
     $this->assertEquals(['creator_name'], $annotations[0]->optFields);
     $this->assertInstanceOf(Alias::class, $annotations[1]);
     $this->assertEquals('creator_id', $annotations[1]->name);
     $this->assertEquals(['maintener_id'], $annotations[1]->alias);
     $this->assertInstanceOf(Alias::class, $annotations[2]);
     $this->assertEquals('creator_name', $annotations[2]->name);
     $this->assertEquals(['maintener_name'], $annotations[2]->alias);
     $this->assertInstanceOf(ColumnType::class, $annotations[3]);
     $this->assertEquals(Target\Editor::class, $annotations[3]->type);
     $this->assertEquals('creator', $annotations[3]->name);
 }
开发者ID:ritalin,项目名称:omelet,代码行数:63,代码来源:AnnotationConverterAdapterTest.php

示例11: testReset

 public function testReset()
 {
     $foo = $this->getMock('JMS\\TranslationBundle\\Translation\\ExtractorInterface');
     $logger = new NullLogger();
     $extractor = new FileExtractor(new \Twig_Environment(), $logger, array());
     $extractor->setExcludedNames(array('foo', 'bar'));
     $extractor->setExcludedDirs(array('baz'));
     $manager = $this->getManager($extractor, array('foo' => $foo));
     $manager->setEnabledExtractors(array('foo' => true));
     $manager->setDirectories(array('/'));
     $managerReflection = new \ReflectionClass($manager);
     $extractorReflection = new \ReflectionClass($extractor);
     $enabledExtractorsProperty = $managerReflection->getProperty('enabledExtractors');
     $enabledExtractorsProperty->setAccessible(true);
     $directoriesProperty = $managerReflection->getProperty('directories');
     $directoriesProperty->setAccessible(true);
     $excludedNamesProperty = $extractorReflection->getProperty('excludedNames');
     $excludedNamesProperty->setAccessible(true);
     $excludedDirsProperty = $extractorReflection->getProperty('excludedDirs');
     $excludedDirsProperty->setAccessible(true);
     $this->assertEquals(array('foo' => true), $enabledExtractorsProperty->getValue($manager));
     $this->assertEquals(array('/'), $directoriesProperty->getValue($manager));
     $this->assertEquals(array('foo', 'bar'), $excludedNamesProperty->getValue($extractor));
     $this->assertEquals(array('baz'), $excludedDirsProperty->getValue($extractor));
     $manager->reset();
     $this->assertEquals(array(), $enabledExtractorsProperty->getValue($manager));
     $this->assertEquals(array(), $directoriesProperty->getValue($manager));
     $this->assertEquals(array(), $excludedNamesProperty->getValue($extractor));
     $this->assertEquals(array(), $excludedDirsProperty->getValue($extractor));
 }
开发者ID:pixel-cookers,项目名称:JMSTranslationBundle,代码行数:30,代码来源:ExtractorManagerTest.php

示例12: testAnnotations

 /**
  * Testing annotations.
  *
  * @test
  * @covers \Bairwell\Hydrator\Annotations\From
  */
 public function testAnnotations()
 {
     $sut = new From();
     $reflection = new \ReflectionClass($sut);
     $this->assertTrue($reflection->isFinal());
     $properties = $reflection->getDefaultProperties();
     $expectedProperties = ['sources' => [], 'field' => null, 'conditions' => []];
     foreach ($expectedProperties as $k => $v) {
         $this->assertArrayHasKey($k, $properties);
         $this->assertEquals($v, $properties[$k]);
     }
     $comments = $reflection->getDocComment();
     $expected = preg_quote('@Annotation');
     $results = preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches);
     $this->assertEquals(1, $results);
     $expected = preg_quote('@Target({"PROPERTY"})');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('sources');
     $comments = $property->getDocComment();
     $expected = '@var\\s+array';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     $expected = '@Required';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     // field
     $property = $reflection->getProperty('field');
     $comments = $property->getDocComment();
     $expected = '@var\\s+string';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     // conditions
     $property = $reflection->getProperty('conditions');
     $comments = $property->getDocComment();
     $expected = '@var\\s+array';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
 }
开发者ID:bairwell,项目名称:hydrator,代码行数:41,代码来源:FromTest.php

示例13: testAnnotations

 /**
  * Testing annotations.
  *
  * @test
  */
 public function testAnnotations()
 {
     $sut = new AsFloat();
     $reflection = new \ReflectionClass($sut);
     $comments = $reflection->getDocComment();
     $expected = preg_quote('@Annotation');
     $results = preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches);
     $this->assertEquals(1, $results);
     $expected = preg_quote('@Target({"PROPERTY"})');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     $property = $reflection->getProperty('allowNull');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var ') . '(bool|boolean)';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('precision');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var ') . '(int|integer)';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('decimalSeparator');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var ') . '(str|string)';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('digitsSeparator');
     $comments = $property->getDocComment();
     $expected = preg_quote('@var ') . '(str|string)';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
 }
开发者ID:bairwell,项目名称:hydrator,代码行数:35,代码来源:AsFloatTest.php

示例14: hydrate

 /**
  * {@inheritdoc}
  */
 public function hydrate($document, MetaInformationInterface $metaInformation)
 {
     $targetEntity = $metaInformation->getEntity();
     $reflectionClass = new \ReflectionClass($targetEntity);
     foreach ($document as $property => $value) {
         if ($property === MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME) {
             $value = $this->removePrefixedKeyFieldName($value);
         }
         // skip field if value is array or "flat" object
         // hydrated object should contain a list of real entities / entity
         if ($this->mapValue($property, $value, $metaInformation) == false) {
             continue;
         }
         try {
             $classProperty = $reflectionClass->getProperty($this->removeFieldSuffix($property));
         } catch (\ReflectionException $e) {
             try {
                 $classProperty = $reflectionClass->getProperty($this->toCamelCase($this->removeFieldSuffix($property)));
             } catch (\ReflectionException $e) {
                 continue;
             }
         }
         $classProperty->setAccessible(true);
         $classProperty->setValue($targetEntity, $value);
     }
     return $targetEntity;
 }
开发者ID:zquintana,项目名称:SolrBundle,代码行数:30,代码来源:ValueHydrator.php

示例15: testSetProxy

 /**
  * test proxy setting
  *
  * @return void
  */
 public function testSetProxy()
 {
     $query = $this->getInstance();
     $query->useProxy(true);
     $reflection = new \ReflectionClass(get_class($query));
     $propertyProxy = $reflection->getProperty('proxy');
     $propertyProxy->setAccessible(true);
     $proxy = $propertyProxy->getValue($query);
     $propertyDynamic = $reflection->getProperty('dynamic');
     $propertyDynamic->setAccessible(true);
     $dynamic = $propertyDynamic->getValue($query);
     $this->assertTrue($proxy);
     $this->assertTrue($dynamic);
     $query->useProxy(false);
     $proxy = $propertyProxy->getValue($query);
     $this->assertFalse($proxy);
     $query->useDynamic(false);
     $dynamic = $propertyDynamic->getValue($query);
     $this->assertFalse($dynamic);
     $setOptions = ['option1', 'option2'];
     $query->setProxyOption($setOptions);
     $property = $reflection->getProperty('options');
     $property->setAccessible(true);
     $options = $property->getValue($query);
     $this->assertEquals($setOptions, $options);
     $query->useProxy(true);
     $proxyManager = m::mock('Xpressengine\\Database\\ProxyManager');
     $proxyManager->shouldReceive('set');
     $this->connector->shouldReceive('getProxyManager')->andReturn($proxyManager);
     $this->assertNull($query->getProxyManager());
     $query->useDynamic(true);
     $this->assertInstanceOf('Xpressengine\\Database\\ProxyManager', $query->getProxyManager());
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:38,代码来源:DynamicQueryTest.php


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