Zend_Reflection-Reference.xml 18 KB

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