1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.reflection.examples">
4 <title>Zend_Reflection Examples</title>
6 <example id="zend.reflection.examples.file">
7 <title>Performing reflection on a file</title>
9 <programlisting language="php"><![CDATA[
10 $r = new Zend_Reflection_File($filename);
18 $classes = $r->getClasses();
19 echo " It has " . count($classes) . ":\n";
20 foreach ($classes as $class) {
21 echo " " . $class->getName() . "\n";
24 $functions = $r->getFunctions();
25 echo " It has " . count($functions) . ":\n";
26 foreach ($functions as $function) {
27 echo " " . $function->getName() . "\n";
32 <example id="zend.reflection.examples.class">
33 <title>Performing reflection on a class</title>
35 <programlisting language="php"><![CDATA[
36 $r = new Zend_Reflection_Class($class);
39 "The class level docblock has the short description: %s\n".
40 "The class level docblock has the long description:\n%s\n",
41 $r->getDocblock()->getShortDescription(),
42 $r->getDocblock()->getLongDescription(),
45 // Get the declaring file reflection
46 $file = $r->getDeclaringFile();
50 <example id="zend.reflection.examples.method">
51 <title>Performing reflection on a method</title>
53 <programlisting language="php"><![CDATA[
54 $r = new Zend_Reflection_Method($class, $name);
57 "The method '%s' has a return type of %s",
62 foreach ($r->getParameters() as $key => $param) {
64 "Param at position '%d' is of type '%s'\n",
72 <example id="zend.reflection.examples.docblock">
73 <title>Performing reflection on a docblock</title>
75 <programlisting language="php"><![CDATA[
76 $r = new Zend_Reflection_Method($class, $name);
77 $docblock = $r->getDocblock();
80 "The short description: %s\n".
81 "The long description:\n%s\n",
82 $r->getDocblock()->getShortDescription(),
83 $r->getDocblock()->getLongDescription(),
86 foreach ($docblock->getTags() as $tag) {
88 "Annotation tag '%s' has the description '%s'\n",
90 $tag->getDescription()