本文整理匯總了PHP中Zend\Code\Reflection\ClassReflection::getProperty方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassReflection::getProperty方法的具體用法?PHP ClassReflection::getProperty怎麽用?PHP ClassReflection::getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Code\Reflection\ClassReflection
的用法示例。
在下文中一共展示了ClassReflection::getProperty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAllowsMultipleParsingStrategies
public function testAllowsMultipleParsingStrategies()
{
$genericParser = new Annotation\Parser\GenericAnnotationParser();
$genericParser->registerAnnotation(__NAMESPACE__ . '\\TestAsset\\Foo');
$doctrineParser = new Annotation\Parser\DoctrineAnnotationParser();
$doctrineParser->registerAnnotation(__NAMESPACE__ . '\\TestAsset\\DoctrineAnnotation');
$this->manager->attach($genericParser);
$this->manager->attach($doctrineParser);
$reflection = new Reflection\ClassReflection(__NAMESPACE__ . '\\TestAsset\\EntityWithMixedAnnotations');
$prop = $reflection->getProperty('test');
$annotations = $prop->getAnnotations($this->manager);
$this->assertTrue($annotations->hasAnnotation(__NAMESPACE__ . '\\TestAsset\\Foo'));
$this->assertTrue($annotations->hasAnnotation(__NAMESPACE__ . '\\TestAsset\\DoctrineAnnotation'));
$this->assertFalse($annotations->hasAnnotation(__NAMESPACE__ . '\\TestAsset\\Bar'));
foreach ($annotations as $annotation) {
switch (get_class($annotation)) {
case __NAMESPACE__ . '\\TestAsset\\Foo':
$this->assertEquals('first', $annotation->content);
break;
case __NAMESPACE__ . '\\TestAsset\\DoctrineAnnotation':
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $annotation->value);
break;
default:
$this->fail('Received unexpected annotation "' . get_class($annotation) . '"');
}
}
}
示例2: testPropertyReturns
public function testPropertyReturns()
{
$reflectionClass = new ClassReflection('ZendTest\\Code\\Reflection\\TestAsset\\TestSampleClass2');
$propertyByName = $reflectionClass->getProperty('_prop1');
$this->assertInstanceOf('Zend\\Code\\Reflection\\PropertyReflection', $propertyByName);
$propertiesAll = $reflectionClass->getProperties();
$this->assertEquals(2, count($propertiesAll));
$firstProperty = array_shift($propertiesAll);
$this->assertEquals('_prop1', $firstProperty->getName());
}