File: Zend_Reflection-Examples.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 (92 lines) | stat: -rw-r--r-- 2,495 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: 24249 -->
<!-- Reviewed: no -->
<sect1 id="zend.reflection.examples">
    <title>Zend_Reflection Exemples</title>

    <example id="zend.reflection.examples.file">
        <title>Effectuer la réflexion sur un fichier</title>

        <programlisting language="php"><![CDATA[
$r = new Zend_Reflection_File($filename);
printf(
    "===> The %s file\n".
    "     has %d lines\n",
    $r->getFileName(),
    $r->getEndLine()
);

$classes = $r->getClasses();
echo "     It has " . count($classes) . ":\n";
foreach ($classes as $class) {
    echo "         " . $class->getName() . "\n";
}

$functions = $r->getFunctions();
echo "     It has " . count($functions) . ":\n";
foreach ($functions as $function) {
    echo "         " . $function->getName() . "\n";
}
]]></programlisting>
    </example>

    <example id="zend.reflection.examples.class">
        <title>Effectuer la réflexion d'une classe</title>

        <programlisting language="php"><![CDATA[
$r = new Zend_Reflection_Class($class);

printf(
    "The class level docblock has the short description: %s\n".
    "The class level docblock has the long description:\n%s\n",
    $r->getDocblock()->getShortDescription(),
    $r->getDocblock()->getLongDescription(),
);

// Get the declaring file reflection
$file = $r->getDeclaringFile();
]]></programlisting>
    </example>

    <example id="zend.reflection.examples.method">
        <title>Effectuer la réflexion d'une méthode</title>

        <programlisting language="php"><![CDATA[
$r = new Zend_Reflection_Method($class, $name);

printf( "Method '%s':\n", $r->getName());

foreach ($r->getParameters() as $key => $param) {
    printf(
        "Param at position '%d' is of type '%s'\n",
        $key,
        $param->getType()
    );
}
]]></programlisting>
    </example>

    <example id="zend.reflection.examples.docblock">
        <title>Effectuer la réflexion d'un bloc de documentation</title>

        <programlisting language="php"><![CDATA[
$r = new Zend_Reflection_Method($class, $name);
$docblock = $r->getDocblock();

printf(
    "The short description: %s\n".
    "The long description:\n%s\n",
    $r->getDocblock()->getShortDescription(),
    $r->getDocblock()->getLongDescription(),
);

foreach ($docblock->getTags() as $tag) {
    printf(
        "Annotation tag '%s' has the description '%s'\n",
        $tag->getName(),
        $tag->getDescription()
    );
}
]]></programlisting>
    </example>
</sect1>