1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.server.reflection">
4 <title>Zend_Server_Reflection</title>
6 <sect2 id="zend.server.reflection.introduction">
7 <title>Introduction</title>
10 <classname>Zend_Server_Reflection</classname> provides a standard mechanism for
11 performing function and class introspection for use with server classes. It is
12 based on <acronym>PHP</acronym> 5's Reflection <acronym>API</acronym>, augmenting it
13 with methods for retrieving parameter and return value types and descriptions, a
14 full list of function and method prototypes (i.e., all possible
15 valid calling combinations), and function or method descriptions.
19 Typically, this functionality will only be used by developers of
20 server classes for the framework.
24 <sect2 id="zend.server.reflection.usage">
28 Basic usage is simple:
31 <programlisting language="php"><![CDATA[
32 $class = Zend_Server_Reflection::reflectClass('My_Class');
33 $function = Zend_Server_Reflection::reflectFunction('my_function');
36 $prototypes = $reflection->getPrototypes();
38 // Loop through each prototype for the function
39 foreach ($prototypes as $prototype) {
41 // Get prototype return type
42 echo "Return type: ", $prototype->getReturnType(), "\n";
44 // Get prototype parameters
45 $parameters = $prototype->getParameters();
47 echo "Parameters: \n";
48 foreach ($parameters as $parameter) {
50 echo " ", $parameter->getType(), "\n";
54 // Get namespace for a class, function, or method.
55 // Namespaces may be set at instantiation time (second argument), or using
57 $reflection->getNamespace();
61 <methodname>reflectFunction()</methodname> returns a
62 <classname>Zend_Server_Reflection_Function</classname> object;
63 <methodname>reflectClass()</methodname> returns a
64 <classname>Zend_Server_Reflection_Class</classname> object. Please refer to
65 the <acronym>API</acronym> documentation to see what methods are available to each.