1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.reflection.reference">
4 <title>Zend_Reflection Reference</title>
7 The various classes in <classname>Zend_Reflection</classname> mimic the
8 <acronym>API</acronym> of <acronym>PHP</acronym>'s <ulink
9 url="http://php.net/reflection">Reflection <acronym>API</acronym></ulink> - with one
10 important difference. <acronym>PHP</acronym>'s Reflection <acronym>API</acronym> does not
11 provide introspection into docblock annotation tags, nor into parameter variable
12 types or return types.
16 <classname>Zend_Reflection</classname> analyzes method docblock annotations to
17 determine parameter variable types and the return type. Specifically,
18 the <code>@param</code> and <code>@return</code> annotations are used.
19 However, you can also check for any other annotation tags, as well as
20 the standard "short" and "long" descriptions.
24 Each reflection object in <classname>Zend_Reflection</classname> overrides the
25 <methodname>getDocblock()</methodname> method to return an instance of
26 <classname>Zend_Reflection_Docblock</classname>. This class provides introspection
27 into the docblocks and annotation tags.
31 <classname>Zend_Reflection_File</classname> is a new reflection class that allows
32 introspection of <acronym>PHP</acronym> files. With it, you can retrieve the classes,
33 functions, and global <acronym>PHP</acronym> code contained in the file.
37 Finally, the various methods that return other reflection objects
38 allow a second parameter, the name of the reflection class to use for
39 the returned reflection object.
42 <sect2 id="zend.reflection.reference.docblock">
43 <title>Zend_Reflection_Docblock</title>
46 <classname>Zend_Reflection_Docblock</classname> is the heart of
47 <classname>Zend_Reflection</classname>'s value-add over <acronym>PHP</acronym>'s
48 Reflection <acronym>API</acronym>. It provides the following methods:
54 <methodname>getContents()</methodname>: returns the full contents of the
61 <methodname>getStartLine()</methodname>: returns the starting position of
62 the docblock within the defining file.
68 <methodname>getEndLine()</methodname>: get last line of docblock within the
75 <methodname>getShortDescription()</methodname>: get the short, one-line
76 description (usually the first line of the docblock).
82 <methodname>getLongDescription()</methodname>: get the long description from
89 <methodname>hasTag($name)</methodname>: determine if the docblock has the
96 <methodname>getTag($name)</methodname>: Retrieve the given annotation tag
97 reflection object, or a boolean <constant>FALSE</constant> if it's not
104 <methodname>getTags($filter)</methodname>: Retrieve all tags, or all tags
105 matching the given <varname>$filter</varname> string. The tags
106 returned will be an array of
107 <classname>Zend_Reflection_Docblock_Tag</classname> objects.
113 <sect2 id="zend.reflection.reference.docblock-tag">
114 <title>Zend_Reflection_Docblock_Tag</title>
117 <classname>Zend_Reflection_Docblock_Tag</classname> provides reflection for
118 individual annotation tags. Most tags consist of only a name and a
119 description. In the case of some special tags, the class provides a
120 factory method for retrieving an instance of the appropriate class.
124 The following methods are defined for
125 <classname>Zend_Reflection_Docblock_Tag</classname>:
131 <methodname>factory($tagDocblockLine)</methodname>: instantiate the
132 appropriate tag reflection class and return it.
138 <methodname>getName()</methodname>: return the annotation tag name.
144 <methodname>getDescription()</methodname>: return the annotation
151 <sect2 id="zend.reflection.reference.docblock-tag-param">
152 <title>Zend_Reflection_Docblock_Tag_Param</title>
155 <classname>Zend_Reflection_Docblock_Tag_Param</classname> is a specialized
156 version of <classname>Zend_Reflection_Docblock_Tag</classname>. The
157 <code>@param</code> annotation tag description consists of the
158 parameter type, variable name, and variable description. It adds the
159 following methods to <classname>Zend_Reflection_Docblock_Tag</classname>:
165 <methodname>getType()</methodname>: return the parameter variable type.
171 <methodname>getVariableName()</methodname>: return the parameter variable
178 <sect2 id="zend.reflection.reference.docblock-tag-return">
179 <title>Zend_Reflection_Docblock_Tag_Return</title>
182 Like <classname>Zend_Reflection_Docblock_Tag_Param</classname>,
183 <classname>Zend_Reflection_Docblock_Tag_Return</classname> is a specialized
184 version of <classname>Zend_Reflection_Docblock_Tag</classname>. The
185 <code>@return</code> annotation tag description consists of the
186 return type and variable description. It adds the following method
187 to <classname>Zend_Reflection_Docblock_Tag</classname>:
193 <methodname>getType()</methodname>: return the return type.
199 <sect2 id="zend.reflection.reference.file">
200 <title>Zend_Reflection_File</title>
203 <classname>Zend_Reflection_File</classname> provides introspection into
204 <acronym>PHP</acronym> files. With it, you can introspect the classes, functions, and
205 bare <acronym>PHP</acronym> code defined in a file. It defines the following methods:
211 <methodname>getFileName()</methodname>: retrieve the filename of the file
218 <methodname>getStartLine()</methodname>: retrieve the starting line of the
225 <methodname>getEndLine()</methodname> retrieve the last line / number of
232 <code>getDocComment($reflectionClass =
233 'Zend_Reflection_Docblock')</code>: retrive the file-level
234 docblock reflection object.
240 <code>getClasses($reflectionClass =
241 'Zend_Reflection_Class')</code>: retrieve an array of
242 reflection objects, one for each class defined in the file.
248 <code>getFunctions($reflectionClass =
249 'Zend_Reflection_Function')</code>: retrieve an array of
250 reflection objects, one for each function defined in the file.
256 <code>getClass($name = null, $reflectionClass =
257 'Zend_Reflection_Class')</code>: retrieve the reflection
258 object for a single class.
264 <methodname>getContents()</methodname>: retrieve the full contents of the
271 <sect2 id="zend.reflection.reference.class">
272 <title>Zend_Reflection_Class</title>
275 <classname>Zend_Reflection_Class</classname> extends
276 <code>ReflectionClass</code>, and follows its <acronym>API</acronym>. It adds one
277 additional method, <methodname>getDeclaringFile()</methodname>, which may be
278 used to retrieve the <classname>Zend_Reflection_File</classname> reflection
279 object for the defining file.
283 Additionally, the following methods add an additional argument for
284 specifying the reflection class to use when fetching a reflection
291 <methodname>getDeclaringFile($reflectionClass =
292 'Zend_Reflection_File')</methodname>
298 <methodname>getDocblock($reflectionClass =
299 'Zend_Reflection_Docblock')</methodname>
305 <methodname>getInterfaces($reflectionClass =
306 'Zend_Reflection_Class')</methodname>
312 <methodname>getMethod($reflectionClass = 'Zend_Reflection_Method')</methodname>
318 <methodname>getMethods($filter = -1, $reflectionClass =
319 'Zend_Reflection_Method')</methodname>
324 <methodname>getParentClass($reflectionClass = 'Zend_Reflection_Class')</methodname>
329 <code>getProperty($name, $reflectionClass = 'Zend_Reflection_Property')</code>
335 <code>getProperties($filter = -1, $reflectionClass =
336 'Zend_Reflection_Property')</code>
342 <sect2 id="zend.reflection.reference.extension">
343 <title>Zend_Reflection_Extension</title>
346 <classname>Zend_Reflection_Extension</classname> extends
347 <code>ReflectionExtension</code>, and follows its <acronym>API</acronym>. It overrides
348 the following methods to add an additional argument for specifying
349 the reflection class to use when fetching a reflection object:
355 <code>getFunctions($reflectionClass =
356 'Zend_Reflection_Function')</code>: retrieve an array of
357 reflection objects representing the functions defined by the extension.
363 <code>getClasses($reflectionClass =
364 'Zend_Reflection_Class')</code>: retrieve an array of
365 reflection objects representing the classes defined by the extension.
371 <sect2 id="zend.reflection.reference.function">
372 <title>Zend_Reflection_Function</title>
375 <classname>Zend_Reflection_Function</classname> adds a method for retrieving
376 the function return type, as well as overrides several methods to
377 allow specifying the reflection class to use for returned reflection
384 <code>getDocblock($reflectionClass =
385 'Zend_Reflection_Docblock')</code>: retrieve the function
386 docblock reflection object.
392 <code>getParameters($reflectionClass =
393 'Zend_Reflection_Parameter')</code>: retrieve an array of
394 all function parameter reflection objects.
400 <methodname>getReturn()</methodname>: retrieve the return type reflection
407 <sect2 id="zend.reflection.reference.method">
408 <title>Zend_Reflection_Method</title>
411 <classname>Zend_Reflection_Method</classname> mirrors
412 <classname>Zend_Reflection_Function</classname>, and only overrides one
419 <code>getParentClass($reflectionClass =
420 'Zend_Reflection_Class')</code>: retrieve the parent class
427 <sect2 id="zend.reflection.reference.parameter">
428 <title>Zend_Reflection_Parameter</title>
431 <classname>Zend_Reflection_Parameter</classname> adds a method for retrieving
432 the parameter type, as well as overrides methods to allow specifying
433 the reflection class to use on returned reflection objects.
439 <code>getDeclaringClass($reflectionClass =
440 'Zend_Reflection_Class')</code>: get the declaring class of
441 the parameter as a reflection object (if available).
447 <code>getClass($reflectionClass =
448 'Zend_Reflection_Class')</code>: get the class of
449 the parameter as a reflection object (if available).
455 <code>getDeclaringFunction($reflectionClass =
456 'Zend_Reflection_Function')</code>: get the function of
457 the parameter as a reflection object (if available).
463 <methodname>getType()</methodname>: get the parameter type.
469 <sect2 id="zend.reflection.reference.property">
470 <title>Zend_Reflection_Property</title>
473 <classname>Zend_Reflection_Property</classname> overrides a single method in
474 order to allow specifying the returned reflection object class:
480 <code>getDeclaringClass($reflectionClass =
481 'Zend_Reflection_Class')</code>: retrieve the declaring
482 class of the property as a reflection object.