本文整理汇总了PHP中Zend\Code\Reflection\ClassReflection::getDocblock方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassReflection::getDocblock方法的具体用法?PHP ClassReflection::getDocblock怎么用?PHP ClassReflection::getDocblock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Reflection\ClassReflection
的用法示例。
在下文中一共展示了ClassReflection::getDocblock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromReflection
/**
* fromReflection() - build a Code Generation Php Object from a Class Reflection
*
* @param ReflectionClass $classReflection
* @return ClassGenerator
*/
public static function fromReflection(ClassReflection $classReflection)
{
// class generator
$cg = new static($classReflection->getName());
$cg->setSourceContent($cg->getSourceContent());
$cg->setSourceDirty(false);
if ($classReflection->getDocComment() != '') {
$cg->setDocblock(DocblockGenerator::fromReflection($classReflection->getDocblock()));
}
$cg->setAbstract($classReflection->isAbstract());
// set the namespace
if ($classReflection->inNamespace()) {
$cg->setNamespaceName($classReflection->getNamespaceName());
}
/* @var $parentClass \Zend\Code\Reflection\ReflectionClass */
if ($parentClass = $classReflection->getParentClass()) {
$cg->setExtendedClass($parentClass->getName());
$interfaces = array_diff($classReflection->getInterfaces(), $parentClass->getInterfaces());
} else {
$interfaces = $classReflection->getInterfaces();
}
$interfaceNames = array();
foreach ($interfaces as $interface) {
/* @var $interface \Zend\Code\Reflection\ReflectionClass */
$interfaceNames[] = $interface->getName();
}
$cg->setImplementedInterfaces($interfaceNames);
$properties = array();
foreach ($classReflection->getProperties() as $reflectionProperty) {
/* @var $reflectionProperty \PropertyReflection\Code\Reflection\ReflectionProperty */
if ($reflectionProperty->getDeclaringClass()->getName() == $cg->getName()) {
$properties[] = PropertyGenerator::fromReflection($reflectionProperty);
}
}
$cg->setProperties($properties);
$methods = array();
foreach ($classReflection->getMethods() as $reflectionMethod) {
/* @var $reflectionMethod \MethodReflection\Code\Reflection\ReflectionMethod */
if ($reflectionMethod->getDeclaringClass()->getName() == $cg->getName()) {
$methods[] = MethodGenerator::fromReflection($reflectionMethod);
}
}
$cg->setMethods($methods);
return $cg;
}
示例2: testToString
public function testToString()
{
$classReflection = new ClassReflection('ZendTest\\Code\\Reflection\\TestAsset\\TestSampleClass5');
$classDocblock = $classReflection->getDocblock();
$expectedString = 'DocBlock [ /* DocBlock */ ] {' . PHP_EOL . PHP_EOL . ' - Tags [1] {' . PHP_EOL . ' DocBlock Tag [ * @author ]' . PHP_EOL . ' }' . PHP_EOL . '}' . PHP_EOL;
$this->assertEquals($expectedString, (string) $classDocblock);
}