Zend_Reflection Exemples
Example #1 Effectuer la réflexion sur un fichier
$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 Effectuer la réflexion d'une classe
$r = new Zend_Reflection_Class($class);
"The class level docblock has the short description: %s\n".
"The class level docblock has the long description:\n%s\n",
$r->getDocblock()->getShortDescription(),
$r->getDocblock()->getLongDescription(),
);
// Get the declaring file reflection
$file = $r->getDeclaringFile();
Example #3 Effectuer la réflexion d'une méthode
$r = new Zend_Reflection_Method($class, $name);
"The method '%s' has a return type of %s",
$r->getName(),
$r->getReturn()
);
foreach ($r->getParameters() as $key => $param) {
"Param at position '%d' is of type '%s'\n",
$key,
$param->getType()
);
}
Example #4 Effectuer la réflexion d'un bloc de documentation
$r = new Zend_Reflection_Method($class, $name);
$docblock = $r->getDocblock();
"The short description: %s\n".
"The long description:\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()
);
}
|
|