Zend_Reflection-Reference.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 15289 -->
  4. <sect1 id="zend.reflection.reference">
  5. <title>Zend_Reflectionリファレンス</title>
  6. <para>
  7. The various classes in <code>Zend_Reflection</code> mimic the API of
  8. PHP's <ulink url="http://php.net/reflection">Reflection API</ulink> -
  9. with one important difference. PHP's Reflection API does not provide
  10. introspection into docblock annotation tags, nor into parameter variable
  11. types or return types.
  12. </para>
  13. <para>
  14. <code>Zend_Reflection</code> analyzes method docblock annotations to
  15. determine parameter variable types and the return type. Specifically,
  16. the <code>@param</code> and <code>@return</code> annotations are used.
  17. However, you can also check for any other annotation tags, as well as
  18. the standard "short" and "long" descriptions.
  19. </para>
  20. <para>
  21. Each reflection object in <code>Zend_Reflection</code> overrides the
  22. <code>getDocblock()</code> method to return an instance of
  23. <code>Zend_Reflection_Docblock</code>. This class provides introspection
  24. into the docblocks and annotation tags.
  25. </para>
  26. <para>
  27. <code>Zend_Reflection_File</code> is a new reflection class that allows
  28. introspection of PHP files. With it, you can retrieve the classes,
  29. functions, and global PHP code contained in the file.
  30. </para>
  31. <para>
  32. Finally, the various methods that return other reflection objects
  33. allow a second parameter, the name of the reflection class to use for
  34. the returned reflection object.
  35. </para>
  36. <sect2 id="zend.reflection.reference.docblock">
  37. <title>Zend_Reflection_Docblock</title>
  38. <para>
  39. <code>Zend_Reflection_Docblock</code> is the heart of
  40. <code>Zend_Reflection</code>'s value-add over PHP's Reflection API.
  41. It provides the following methods:
  42. </para>
  43. <itemizedlist>
  44. <listitem><para>
  45. <code>getContents()</code>: docblockの完全な内容を返す
  46. </para></listitem>
  47. <listitem><para>
  48. <code>getStartLine()</code>: 定義されたファイル内での
  49. docblock開始位置を返す
  50. </para></listitem>
  51. <listitem><para>
  52. <code>getEndLine()</code>: 定義されたファイル内での
  53. docblock終了行を返す
  54. </para></listitem>
  55. <listitem><para>
  56. <code>getShortDescription()</code>: 短い、一行の説明を取得
  57. (たいていはdocblockの最初の行)
  58. </para></listitem>
  59. <listitem><para>
  60. <code>getLongDescription()</code>: docblockの長い説明を取得
  61. </para></listitem>
  62. <listitem><para>
  63. <code>hasTag($name)</code>: 与えられた注釈タグが
  64. docblockにあるかどうか判断する。
  65. </para></listitem>
  66. <listitem><para>
  67. <code>getTag($name)</code>: Retrieve the given annotation tag
  68. reflection object, or a boolean <code>false</code> if it's not
  69. present.
  70. </para></listitem>
  71. <listitem><para>
  72. <code>getTags($filter)</code>: Retrieve all tags, or all tags
  73. matching the given <code>$filter</code> string. The tags
  74. returned will be an array of
  75. <code>Zend_Reflection_Docblock_Tag</code> objects.
  76. </para></listitem>
  77. </itemizedlist>
  78. </sect2>
  79. <sect2 id="zend.reflection.reference.docblock-tag">
  80. <title>Zend_Reflection_Docblock_Tag</title>
  81. <para>
  82. <code>Zend_Reflection_Docblock_Tag</code> provides reflection for
  83. individual annotation tags. Most tags consist of only a name and a
  84. description. In the case of some special tags, the class provides a
  85. factory method for retrieving an instance of the appropriate class.
  86. </para>
  87. <para>
  88. The following methods are defined for
  89. <code>Zend_Reflection_Docblock_Tag</code>:
  90. </para>
  91. <itemizedlist>
  92. <listitem><para>
  93. <code>factory($tagDocblockLine)</code>: instantiate the
  94. appropriate tag reflection class and return it.
  95. </para></listitem>
  96. <listitem><para>
  97. <code>getName()</code>: 注釈タグの名前を返す
  98. </para></listitem>
  99. <listitem><para>
  100. <code>getDescription()</code>: 注釈の説明を返す
  101. </para></listitem>
  102. </itemizedlist>
  103. </sect2>
  104. <sect2 id="zend.reflection.reference.docblock-tag-param">
  105. <title>Zend_Reflection_Docblock_Tag_Param</title>
  106. <para>
  107. <code>Zend_Reflection_Docblock_Tag_Param</code> is a specialized
  108. version of <code>Zend_Reflection_Docblock_Tag</code>. The
  109. <code>@param</code> annotation tag description consists of the
  110. parameter type, variable name, and variable description. It adds the
  111. following methods to <code>Zend_Reflection_Docblock_Tag</code>:
  112. </para>
  113. <itemizedlist>
  114. <listitem><para>
  115. <code>getType()</code>: パラメータ変数の型を返す
  116. </para></listitem>
  117. <listitem><para>
  118. <code>getVariableName()</code>: パラメータ変数の名前を返す
  119. </para></listitem>
  120. </itemizedlist>
  121. </sect2>
  122. <sect2 id="zend.reflection.reference.docblock-tag-return">
  123. <title>Zend_Reflection_Docblock_Tag_Return</title>
  124. <para>
  125. Like <code>Zend_Reflection_Docblock_Tag_Param</code>,
  126. <code>Zend_Reflection_Docblock_Tag_Return</code> is a specialized
  127. version of <code>Zend_Reflection_Docblock_Tag</code>. The
  128. <code>@return</code> annotation tag description consists of the
  129. return type and variable description. It adds the following method
  130. to <code>Zend_Reflection_Docblock_Tag</code>:
  131. </para>
  132. <itemizedlist>
  133. <listitem><para>
  134. <code>getType()</code>: 戻す型を返す
  135. </para></listitem>
  136. </itemizedlist>
  137. </sect2>
  138. <sect2 id="zend.reflection.reference.file">
  139. <title>Zend_Reflection_File</title>
  140. <para>
  141. <code>Zend_Reflection_File</code> provides introspection into PHP
  142. files. With it, you can introspect the classes, functions, and bare
  143. PHP code defined in a file. It defines the following methods:
  144. </para>
  145. <itemizedlist>
  146. <listitem><para>
  147. <code>getFileName()</code>: reflectionを使用したファイルの名前を取得
  148. </para></listitem>
  149. <listitem><para>
  150. <code>getStartLine()</code>: ファイルの開始行を返す(常に1)
  151. </para></listitem>
  152. <listitem><para>
  153. <code>getEndLine()</code> 最終行、ファイル中の行数を取得
  154. </para></listitem>
  155. <listitem><para>
  156. <code>getDocComment($reflectionClass =
  157. 'Zend_Reflection_Docblock')</code>: retrive the file-level
  158. docblock reflection object.
  159. </para></listitem>
  160. <listitem><para>
  161. <code>getClasses($reflectionClass =
  162. 'Zend_Reflection_Class')</code>: retrieve an array of
  163. reflection objects, one for each class defined in the file.
  164. </para></listitem>
  165. <listitem><para>
  166. <code>getFunctions($reflectionClass =
  167. 'Zend_Reflection_Function')</code>: retrieve an array of
  168. reflection objects, one for each function defined in the file.
  169. </para></listitem>
  170. <listitem><para>
  171. <code>getClass($name = null, $reflectionClass =
  172. 'Zend_Reflection_Class')</code>: retrieve the reflection
  173. object for a single class.
  174. </para></listitem>
  175. <listitem><para>
  176. <code>getContents()</code>: retrieve the full contents of the
  177. file.
  178. </para></listitem>
  179. </itemizedlist>
  180. </sect2>
  181. <sect2 id="zend.reflection.reference.class">
  182. <title>Zend_Reflection_Class</title>
  183. <para>
  184. <code>Zend_Reflection_Class</code> extends
  185. <code>ReflectionClass</code>, and follows its API. It adds one
  186. additional method, <code>getDeclaringFile()</code>, which may be
  187. used to retrieve the <code>Zend_Reflection_File</code> reflection
  188. object for the defining file.
  189. </para>
  190. <para>
  191. Additionally, the following methods add an additional argument for
  192. specifying the reflection class to use when fetching a reflection
  193. object:
  194. </para>
  195. <itemizedlist>
  196. <listitem><para>
  197. <code>getDeclaringFile($reflectionClass = 'Zend_Reflection_File')</code>
  198. </para></listitem>
  199. <listitem><para>
  200. <code>getDocblock($reflectionClass = 'Zend_Reflection_Docblock')</code>
  201. </para></listitem>
  202. <listitem><para>
  203. <code>getInterfaces($reflectionClass = 'Zend_Reflection_Class')</code>
  204. </para></listitem>
  205. <listitem><para>
  206. <code>getMethod($reflectionClass = 'Zend_Reflection_Method')</code>
  207. </para></listitem>
  208. <listitem><para>
  209. <code>getMethods($filter = -1, $reflectionClass = 'Zend_Reflection_Method')</code>
  210. </para></listitem>
  211. <listitem><para>
  212. <code>getParentClass($reflectionClass = 'Zend_Reflection_Class')</code>
  213. </para></listitem>
  214. <listitem><para>
  215. <code>getProperty($name, $reflectionClass =
  216. 'Zend_Reflection_Property')</code>
  217. </para></listitem>
  218. <listitem><para>
  219. <code>getProperties($filter = -1, $reflectionClass =
  220. 'Zend_Reflection_Property')</code>
  221. </para></listitem>
  222. </itemizedlist>
  223. </sect2>
  224. <sect2 id="zend.reflection.reference.extension">
  225. <title>Zend_Reflection_Extension</title>
  226. <para>
  227. <code>Zend_Reflection_Extension</code> extends
  228. <code>ReflectionExtension</code>, and follows its API. It overrides
  229. the following methods to add an additional argument for specifying
  230. the reflection class to use when fetching a reflection object:
  231. </para>
  232. <itemizedlist>
  233. <listitem><para>
  234. <code>getFunctions($reflectionClass =
  235. 'Zend_Reflection_Function')</code>: retrieve an array of
  236. reflection objects representing the functions defined by the
  237. extension.
  238. </para></listitem>
  239. <listitem><para>
  240. <code>getClasses($reflectionClass =
  241. 'Zend_Reflection_Class')</code>: retrieve an array of
  242. reflection objects representing the classes defined by the
  243. extension.
  244. </para></listitem>
  245. </itemizedlist>
  246. </sect2>
  247. <sect2 id="zend.reflection.reference.function">
  248. <title>Zend_Reflection_Function</title>
  249. <para>
  250. <code>Zend_Reflection_Function</code> adds a method for retrieving
  251. the function return type, as well as overrides several methods to
  252. allow specifying the reflection class to use for returned reflection
  253. objects.
  254. </para>
  255. <itemizedlist>
  256. <listitem><para>
  257. <code>getDocblock($reflectionClass =
  258. 'Zend_Reflection_Docblock')</code>: retrieve the function
  259. docblock reflection object.
  260. </para></listitem>
  261. <listitem><para>
  262. <code>getParameters($reflectionClass =
  263. 'Zend_Reflection_Parameter')</code>: retrieve an array of
  264. all function parameter reflection objects.
  265. </para></listitem>
  266. <listitem><para>
  267. <code>getReturn()</code>: retrieve the return type reflection
  268. object.
  269. </para></listitem>
  270. </itemizedlist>
  271. </sect2>
  272. <sect2 id="zend.reflection.reference.method">
  273. <title>Zend_Reflection_Method</title>
  274. <para>
  275. <code>Zend_Reflection_Method</code> mirrors
  276. <code>Zend_Reflection_Function</code>, and only overrides one
  277. additional method:
  278. </para>
  279. <itemizedlist>
  280. <listitem><para>
  281. <code>getParentClass($reflectionClass =
  282. 'Zend_Reflection_Class')</code>: retrieve the parent class
  283. reflection object.
  284. </para></listitem>
  285. </itemizedlist>
  286. </sect2>
  287. <sect2 id="zend.reflection.reference.parameter">
  288. <title>Zend_Reflection_Parameter</title>
  289. <para>
  290. <code>Zend_Reflection_Parameter</code> adds a method for retrieving
  291. the parameter type, as well as overrides methods to allow specifying
  292. the reflection class to use on returned reflection objects.
  293. </para>
  294. <itemizedlist>
  295. <listitem><para>
  296. <code>getDeclaringClass($reflectionClass =
  297. 'Zend_Reflection_Class')</code>: get the declaring class of
  298. the parameter as a reflection object (if available).
  299. </para></listitem>
  300. <listitem><para>
  301. <code>getClass($reflectionClass =
  302. 'Zend_Reflection_Class')</code>: get the class of
  303. the parameter as a reflection object (if available).
  304. </para></listitem>
  305. <listitem><para>
  306. <code>getDeclaringFunction($reflectionClass =
  307. 'Zend_Reflection_Function')</code>: get the function of
  308. the parameter as a reflection object (if available).
  309. </para></listitem>
  310. <listitem><para>
  311. <code>getType()</code>: パラメータの型を取得
  312. </para></listitem>
  313. </itemizedlist>
  314. </sect2>
  315. <sect2 id="zend.reflection.reference.property">
  316. <title>Zend_Reflection_Property</title>
  317. <para>
  318. <code>Zend_Reflection_Property</code> overrides a single method in
  319. order to allow specifying the returned reflection object class:
  320. </para>
  321. <itemizedlist>
  322. <listitem><para>
  323. <code>getDeclaringClass($reflectionClass =
  324. 'Zend_Reflection_Class')</code>: retrieve the declaring
  325. class of the property as a reflection object.
  326. </para></listitem>
  327. </itemizedlist>
  328. </sect2>
  329. </sect1>