Introduction | Zend_Server Programmer's Reference Guide | Zend_Service

# Zend_Server_Reflection

# Introduction

Zend_Server_Reflection provides a standard mechanism for performing function and class introspection for use with server classes. It is based on PHP 5's Reflection API, augmenting it with methods for retrieving parameter and return value types and descriptions, a full list of function and method prototypes (i.e., all possible valid calling combinations), and function or method descriptions.

Typically, this functionality will only be used by developers of server classes for the framework.

# Usage

Basic usage is simple:

1. $class = Zend_Server_Reflection::reflectClass('My_Class');
2. $function = Zend_Server_Reflection::reflectFunction('my_function');
4. // Get prototypes
5. $prototypes = $reflection->getPrototypes();
7. // Loop through each prototype for the function
8. foreach ($prototypes as $prototype) {
10. // Get prototype return type
11. echo "Return type: ", $prototype->getReturnType(), "\n";
13. // Get prototype parameters
14. $parameters = $prototype->getParameters();
16. echo "Parameters: \n";
17. foreach ($parameters as $parameter) {
18. // Get parameter type
19. echo " ", $parameter->getType(), "\n";
20. }
21. }
23. // Get namespace for a class, function, or method.
24. // Namespaces may be set at instantiation time (second argument), or using
25. // setNamespace()
26. $reflection->getNamespace();

reflectFunction() returns a Zend_Server_Reflection_Function object; reflectClass() returns a Zend_Server_Reflection_Class object. Please refer to the API documentation to see what methods are available to each.

Introduction | Zend_Server Programmer's Reference Guide | Zend_Service