Zend_Reflectionサンプル
Example #1 ファイルでreflectionを実行
$r = new Zend_Reflection_File($filename);
"===> The %s file\n".
" has %d lines\n",
$r->getFileName(),
$r->getEndLine()
);
$classes = $r->getClasses();
foreach ($classes as $class) {
echo " " . $class-> getName() . "\n";
}
$functions = $r->getFunctions();
foreach ($functions as $function) {
echo " " . $function-> getName() . "\n";
}
Example #2 クラスでreflectionを実行
$r = new Zend_Reflection_Class($class);
"クラスレベルのdocblockの短い記述: %s\n".
"クラスレベルのdocblockの長い記述:\n%s\n",
$r->getDocblock()->getShortDescription(),
$r->getDocblock()->getLongDescription(),
);
//宣言するファイルreflectionを取得
$file = $r->getDeclaringFile();
Example #3 メソッドでreflectionを実行
$r = new Zend_Reflection_Method($class, $name);
printf( "Method '%s':\n", $r-> getName());
foreach ($r->getParameters() as $key => $param) {
"Param at position '%d' is of type '%s'\n",
$key,
$param->getType()
);
}
Example #4 docblockでreflectionを実行
$r = new Zend_Reflection_Method($class, $name);
$docblock = $r->getDocblock();
"短い記述: %s\n".
"長い記述:\n%s\n",
$r->getDocblock()->getShortDescription(),
$r->getDocblock()->getLongDescription(),
);
foreach ($docblock->getTags() as $tag) {
"Annotation tag '%s' has the description '%s'\n",
$tag->getName(),
$tag->getDescription()
);
}
|
|