|
|
@@ -0,0 +1,97 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- Reviewed: no -->
|
|
|
+<!-- EN-Revision: 15192 -->
|
|
|
+<sect1 id="zend.reflection.examples">
|
|
|
+ <title>Zend_Reflectionサンプル</title>
|
|
|
+
|
|
|
+ <example id="zend.reflection.examples.file">
|
|
|
+ <title>ファイルでreflectionを実行</title>
|
|
|
+
|
|
|
+ <programlisting role="php"><![CDATA[
|
|
|
+$r = new Zend_Reflection_File($filename);
|
|
|
+printf(
|
|
|
+ "===> The %s file\n".
|
|
|
+ " has %d lines\n",
|
|
|
+ $r->getFileName(),
|
|
|
+ $r->getEndLine()
|
|
|
+);
|
|
|
+
|
|
|
+$classes = $r->getClasses();
|
|
|
+echo " It has " . count($classes) . ":\n";
|
|
|
+foreach ($classes as $class) {
|
|
|
+ echo " " . $class->getName() . "\n";
|
|
|
+}
|
|
|
+
|
|
|
+$functions = $r->getFunctions();
|
|
|
+echo " It has " . count($functions) . ":\n";
|
|
|
+foreach ($functions as $function) {
|
|
|
+ echo " " . $function->getName() . "\n";
|
|
|
+}
|
|
|
+
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.reflection.examples.class">
|
|
|
+ <title>クラスでreflectionを実行</title>
|
|
|
+
|
|
|
+ <programlisting role="php"><![CDATA[
|
|
|
+$r = new Zend_Reflection_Class($class);
|
|
|
+
|
|
|
+printf(
|
|
|
+ "クラスレベルのdocblockの短い記述: %s\n".
|
|
|
+ "クラスレベルのdocblockの長い記述:\n%s\n",
|
|
|
+ $r->getDocblock()->getShortDescription(),
|
|
|
+ $r->getDocblock()->getLongDescription(),
|
|
|
+);
|
|
|
+
|
|
|
+//宣言するファイルreflectionを取得
|
|
|
+$file = $r->getDeclaringFile();
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.reflection.examples.method">
|
|
|
+ <title>メソッドでreflectionを実行</title>
|
|
|
+
|
|
|
+ <programlisting role="php"><![CDATA[
|
|
|
+$r = new Zend_Reflection_Method($class, $name);
|
|
|
+
|
|
|
+printf(
|
|
|
+"The method '%s' has a return type of %s",
|
|
|
+ $r->getName(),
|
|
|
+ $r->getReturn()
|
|
|
+);
|
|
|
+
|
|
|
+foreach ($r->getParameters() as $key => $param) {
|
|
|
+ printf(
|
|
|
+ "Param at position '%d' is of type '%s'\n",
|
|
|
+ $key,
|
|
|
+ $param->getType()
|
|
|
+ );
|
|
|
+}
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.reflection.examples.docblock">
|
|
|
+ <title>docblockでreflectionを実行</title>
|
|
|
+
|
|
|
+ <programlisting role="php"><![CDATA[
|
|
|
+$r = new Zend_Reflection_Method($class, $name);
|
|
|
+$docblock = $r->getDocblock();
|
|
|
+
|
|
|
+printf(
|
|
|
+ "短い記述: %s\n".
|
|
|
+ "長い記述:\n%s\n",
|
|
|
+ $r->getDocblock()->getShortDescription(),
|
|
|
+ $r->getDocblock()->getLongDescription(),
|
|
|
+);
|
|
|
+
|
|
|
+foreach ($docblock->getTags() as $tag) {
|
|
|
+ printf(
|
|
|
+ "Annotation tag '%s' has the description '%s'\n",
|
|
|
+ $tag->getName(),
|
|
|
+ $tag->getDescription()
|
|
|
+ );
|
|
|
+}
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+</sect1>
|