Skip to content

Commit 8e51769

Browse files
authored
[Sync EN] reflection: übersetze ReflectionFunction::__construct (#283)
1 parent 75c3075 commit 8e51769

1 file changed

Lines changed: 171 additions & 0 deletions

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- EN-Revision: 629dfc9ec496d66c49b626dfc72a4981e74d6250 Maintainer: lacatoire Status: ready -->
3+
<!-- Reviewed: no -->
4+
<refentry xml:id="reflectionfunction.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5+
<refnamediv>
6+
<refname>ReflectionFunction::__construct</refname>
7+
<refpurpose>Erzeugt ein ReflectionFunction-Objekt</refpurpose>
8+
</refnamediv>
9+
10+
<refsect1 role="description">
11+
&reftitle.description;
12+
<constructorsynopsis role="ReflectionFunction">
13+
<modifier>public</modifier> <methodname>ReflectionFunction::__construct</methodname>
14+
<methodparam><type class="union"><type>Closure</type><type>string</type></type><parameter>function</parameter></methodparam>
15+
</constructorsynopsis>
16+
<para>
17+
Erzeugt ein <classname>ReflectionFunction</classname>-Objekt.
18+
</para>
19+
</refsect1>
20+
21+
<refsect1 role="parameters">
22+
&reftitle.parameters;
23+
<para>
24+
<variablelist>
25+
<varlistentry>
26+
<term><parameter>function</parameter></term>
27+
<listitem>
28+
<para>
29+
Der Name der zu reflektierenden Funktion oder eine <link linkend="functions.anonymous">Closure</link>.
30+
</para>
31+
</listitem>
32+
</varlistentry>
33+
</variablelist>
34+
</para>
35+
</refsect1>
36+
37+
<refsect1 role="errors">
38+
&reftitle.errors;
39+
<para>
40+
Eine <classname>ReflectionException</classname>, wenn der Parameter
41+
<parameter>function</parameter> keine gültige Funktion enthält.
42+
</para>
43+
</refsect1>
44+
45+
<refsect1 role="examples">
46+
&reftitle.examples;
47+
<para>
48+
<example>
49+
<title><methodname>ReflectionFunction::__construct</methodname>-Beispiel</title>
50+
<programlisting role="php">
51+
<![CDATA[
52+
<?php
53+
/**
54+
* Ein einfacher Zähler
55+
*
56+
* @return int
57+
*/
58+
function counter1()
59+
{
60+
static $c = 0;
61+
return ++$c;
62+
}
63+
64+
/**
65+
* Ein weiterer einfacher Zähler
66+
*
67+
* @return int
68+
*/
69+
$counter2 = function()
70+
{
71+
static $d = 0;
72+
return ++$d;
73+
74+
};
75+
76+
function dumpReflectionFunction($func)
77+
{
78+
// Grundlegende Informationen ausgeben
79+
printf(
80+
"\n\n===> The %s function '%s'\n".
81+
" declared in %s\n".
82+
" lines %d to %d\n",
83+
$func->isInternal() ? 'internal' : 'user-defined',
84+
$func->getName(),
85+
$func->getFileName(),
86+
$func->getStartLine(),
87+
$func->getEndline()
88+
);
89+
90+
// Dokumentationskommentar ausgeben
91+
printf("---> Documentation:\n %s\n", var_export($func->getDocComment(), true));
92+
93+
// Statische Variablen ausgeben, falls vorhanden
94+
if ($statics = $func->getStaticVariables())
95+
{
96+
printf("---> Static variables: %s\n", var_export($statics, true));
97+
}
98+
}
99+
100+
// Eine Instanz der Klasse ReflectionFunction erzeugen
101+
dumpReflectionFunction(new ReflectionFunction('counter1'));
102+
dumpReflectionFunction(new ReflectionFunction($counter2));
103+
?>
104+
]]>
105+
</programlisting>
106+
&example.outputs.similar;
107+
<screen>
108+
<![CDATA[
109+
===> The user-defined function 'counter1'
110+
declared in Z:\reflectcounter.php
111+
lines 7 to 11
112+
---> Documentation:
113+
'/**
114+
* Ein einfacher Zähler
115+
*
116+
* @return int
117+
*/'
118+
---> Static variables: array (
119+
'c' => 0,
120+
)
121+
122+
123+
===> The user-defined function '{closure}'
124+
declared in Z:\reflectcounter.php
125+
lines 18 to 23
126+
---> Documentation:
127+
'/**
128+
* Ein weiterer einfacher Zähler
129+
*
130+
* @return int
131+
*/'
132+
---> Static variables: array (
133+
'd' => 0,
134+
)
135+
]]>
136+
</screen>
137+
</example>
138+
</para>
139+
</refsect1>
140+
141+
<refsect1 role="seealso">
142+
&reftitle.seealso;
143+
<para>
144+
<simplelist>
145+
<member><methodname>ReflectionMethod::__construct</methodname></member>
146+
<member><link linkend="language.oop5.decon.constructor">Konstruktoren</link></member>
147+
</simplelist>
148+
</para>
149+
</refsect1>
150+
151+
</refentry>
152+
<!-- Keep this comment at the end of the file
153+
Local variables:
154+
mode: sgml
155+
sgml-omittag:t
156+
sgml-shorttag:t
157+
sgml-minimize-attributes:nil
158+
sgml-always-quote-attributes:t
159+
sgml-indent-step:1
160+
sgml-indent-data:t
161+
indent-tabs-mode:nil
162+
sgml-parent-document:nil
163+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
164+
sgml-exposed-tags:nil
165+
sgml-local-catalogs:nil
166+
sgml-local-ecat-files:nil
167+
End:
168+
vim600: syn=xml fen fdm=syntax fdl=2 si
169+
vim: et tw=78 syn=sgml
170+
vi: ts=1 sw=1
171+
-->

0 commit comments

Comments
 (0)