2
0

Zend_Server_Reflection.xml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  9. performing function and class introspection for use with server classes. It is
  10. based on <acronym>PHP</acronym> 5's Reflection <acronym>API</acronym>, augmenting it
  11. with methods 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 or 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. <methodname>reflectFunction()</methodname> returns a
  49. <classname>Zend_Server_Reflection_Function</classname> object;
  50. <methodname>reflectClass()</methodname> returns a
  51. <classname>Zend_Server_Reflection_Class</classname> object. Please refer to
  52. the <acronym>API</acronym> 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. -->