Zend_Reflection-Reference.xml 16 KB

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