1 <?xml version="1.0" encoding="UTF-8"?>
3 <!-- EN-Revision: 15617 -->
4 <sect1 id="zend.reflection.examples">
5 <title>Zend_Reflectionサンプル</title>
7 <example id="zend.reflection.examples.file">
8 <title>ファイルでreflectionを実行</title>
10 <programlisting language="php"><![CDATA[
11 $r = new Zend_Reflection_File($filename);
19 $classes = $r->getClasses();
20 echo " It has " . count($classes) . ":\n";
21 foreach ($classes as $class) {
22 echo " " . $class->getName() . "\n";
25 $functions = $r->getFunctions();
26 echo " It has " . count($functions) . ":\n";
27 foreach ($functions as $function) {
28 echo " " . $function->getName() . "\n";
33 <example id="zend.reflection.examples.class">
34 <title>クラスでreflectionを実行</title>
36 <programlisting language="php"><![CDATA[
37 $r = new Zend_Reflection_Class($class);
40 "クラスレベルのdocblockの短い記述: %s\n".
41 "クラスレベルのdocblockの長い記述:\n%s\n",
42 $r->getDocblock()->getShortDescription(),
43 $r->getDocblock()->getLongDescription(),
46 //宣言するファイルreflectionを取得
47 $file = $r->getDeclaringFile();
51 <example id="zend.reflection.examples.method">
52 <title>メソッドでreflectionを実行</title>
54 <programlisting language="php"><![CDATA[
55 $r = new Zend_Reflection_Method($class, $name);
58 "The method '%s' has a return type of %s",
63 foreach ($r->getParameters() as $key => $param) {
65 "Param at position '%d' is of type '%s'\n",
73 <example id="zend.reflection.examples.docblock">
74 <title>docblockでreflectionを実行</title>
76 <programlisting language="php"><![CDATA[
77 $r = new Zend_Reflection_Method($class, $name);
78 $docblock = $r->getDocblock();
83 $r->getDocblock()->getShortDescription(),
84 $r->getDocblock()->getLongDescription(),
87 foreach ($docblock->getTags() as $tag) {
89 "Annotation tag '%s' has the description '%s'\n",
91 $tag->getDescription()