Zend_Server_Reflection.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.server.reflection">
  4. <title>Zend_Server_Reflection</title>
  5. <sect2 id="zend.server.reflection.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Server_Reflection</classname> provides a standard mechanism for performing
  9. function and class introspection for use with server classes. It is
  10. based on PHP 5's Reflection API, augmenting it with methods
  11. for retrieving parameter and return value types and descriptions, a
  12. full list of function and method prototypes (i.e., all possible
  13. valid calling combinations), and function/method descriptions.
  14. </para>
  15. <para>
  16. Typically, this functionality will only be used by developers of
  17. server classes for the framework.
  18. </para>
  19. </sect2>
  20. <sect2 id="zend.server.reflection.usage">
  21. <title>Usage</title>
  22. <para>
  23. Basic usage is simple:
  24. </para>
  25. <programlisting language="php"><![CDATA[
  26. $class = Zend_Server_Reflection::reflectClass('My_Class');
  27. $function = Zend_Server_Reflection::reflectFunction('my_function');
  28. // Get prototypes
  29. $prototypes = $reflection->getPrototypes();
  30. // Loop through each prototype for the function
  31. foreach ($prototypes as $prototype) {
  32. // Get prototype return type
  33. echo "Return type: ", $prototype->getReturnType(), "\n";
  34. // Get prototype parameters
  35. $parameters = $prototype->getParameters();
  36. echo "Parameters: \n";
  37. foreach ($parameters as $parameter) {
  38. // Get parameter type
  39. echo " ", $parameter->getType(), "\n";
  40. }
  41. }
  42. // Get namespace for a class, function, or method.
  43. // Namespaces may be set at instantiation time (second argument), or using
  44. // setNamespace()
  45. $reflection->getNamespace();
  46. ]]></programlisting>
  47. <para>
  48. <code>reflectFunction()</code> returns a
  49. <classname>Zend_Server_Reflection_Function</classname> object;
  50. <code>reflectClass</code> returns a
  51. <classname>Zend_Server_Reflection_Class</classname> object. Please refer to
  52. the API documentation to see what methods are available to each.
  53. </para>
  54. </sect2>
  55. </sect1>
  56. <!--
  57. vim:se ts=4 sw=4 et:
  58. -->