Zend_Reflection-Examples.xml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 24249 -->
  4. <sect1 id="zend.reflection.examples">
  5. <title>Zend_Reflectionサンプル</title>
  6. <example id="zend.reflection.examples.file">
  7. <title>ファイルでreflectionを実行</title>
  8. <programlisting language="php"><![CDATA[
  9. $r = new Zend_Reflection_File($filename);
  10. printf(
  11. "===> The %s file\n".
  12. " has %d lines\n",
  13. $r->getFileName(),
  14. $r->getEndLine()
  15. );
  16. $classes = $r->getClasses();
  17. echo " It has " . count($classes) . ":\n";
  18. foreach ($classes as $class) {
  19. echo " " . $class->getName() . "\n";
  20. }
  21. $functions = $r->getFunctions();
  22. echo " It has " . count($functions) . ":\n";
  23. foreach ($functions as $function) {
  24. echo " " . $function->getName() . "\n";
  25. }
  26. ]]></programlisting>
  27. </example>
  28. <example id="zend.reflection.examples.class">
  29. <title>クラスでreflectionを実行</title>
  30. <programlisting language="php"><![CDATA[
  31. $r = new Zend_Reflection_Class($class);
  32. printf(
  33. "クラスレベルのdocblockの短い記述: %s\n".
  34. "クラスレベルのdocblockの長い記述:\n%s\n",
  35. $r->getDocblock()->getShortDescription(),
  36. $r->getDocblock()->getLongDescription(),
  37. );
  38. //宣言するファイルreflectionを取得
  39. $file = $r->getDeclaringFile();
  40. ]]></programlisting>
  41. </example>
  42. <example id="zend.reflection.examples.method">
  43. <title>メソッドでreflectionを実行</title>
  44. <programlisting language="php"><![CDATA[
  45. $r = new Zend_Reflection_Method($class, $name);
  46. printf( "Method '%s':\n", $r->getName());
  47. foreach ($r->getParameters() as $key => $param) {
  48. printf(
  49. "Param at position '%d' is of type '%s'\n",
  50. $key,
  51. $param->getType()
  52. );
  53. }
  54. ]]></programlisting>
  55. </example>
  56. <example id="zend.reflection.examples.docblock">
  57. <title>docblockでreflectionを実行</title>
  58. <programlisting language="php"><![CDATA[
  59. $r = new Zend_Reflection_Method($class, $name);
  60. $docblock = $r->getDocblock();
  61. printf(
  62. "短い記述: %s\n".
  63. "長い記述:\n%s\n",
  64. $r->getDocblock()->getShortDescription(),
  65. $r->getDocblock()->getLongDescription(),
  66. );
  67. foreach ($docblock->getTags() as $tag) {
  68. printf(
  69. "Annotation tag '%s' has the description '%s'\n",
  70. $tag->getName(),
  71. $tag->getDescription()
  72. );
  73. }
  74. ]]></programlisting>
  75. </example>
  76. </sect1>