File: Zend_Server_Reflection.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (71 lines) | stat: -rw-r--r-- 2,427 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.server.reflection">
    <title>Zend_Server_Reflection</title>

    <sect2 id="zend.server.reflection.introduction">
        <title>Introduction</title>

        <para>
            <classname>Zend_Server_Reflection</classname> provides a standard mechanism for
            performing function and class introspection for use with server classes. It is
            based on <acronym>PHP</acronym> 5's Reflection <acronym>API</acronym>, 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.
        </para>

        <para>
            Typically, this functionality will only be used by developers of
            server classes for the framework.
        </para>
    </sect2>

    <sect2 id="zend.server.reflection.usage">
        <title>Usage</title>

        <para>
            Basic usage is simple:
        </para>

        <programlisting language="php"><![CDATA[
$class    = Zend_Server_Reflection::reflectClass('My_Class');
$function = Zend_Server_Reflection::reflectFunction('my_function');

// Get prototypes
$prototypes = $reflection->getPrototypes();

// Loop through each prototype for the function
foreach ($prototypes as $prototype) {

    // Get prototype return type
    echo "Return type: ", $prototype->getReturnType(), "\n";

    // Get prototype parameters
    $parameters = $prototype->getParameters();

    echo "Parameters: \n";
    foreach ($parameters as $parameter) {
        // Get parameter type
        echo "    ", $parameter->getType(), "\n";
    }
}

// Get namespace for a class, function, or method.
// Namespaces may be set at instantiation time (second argument), or using
// setNamespace()
$reflection->getNamespace();
]]></programlisting>

        <para>
            <methodname>reflectFunction()</methodname> returns a
            <classname>Zend_Server_Reflection_Function</classname> object;
            <methodname>reflectClass()</methodname> returns a
            <classname>Zend_Server_Reflection_Class</classname> object. Please refer to
            the <acronym>API</acronym> documentation to see what methods are available to each.
        </para>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->