reference/runkit7/functions/runkit7-method-redefine.xml
917c06eac884740ef9285f59387a3f5259d66722
...
...
@@ -0,0 +1,203 @@
1
+
<?xml version="1.0" encoding="utf-8"?>
2
+
<!-- $Revision$ -->
3
+

4
+
<refentry xml:id="function.runkit7-method-redefine" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
+
<refnamediv>
6
+
<refname>runkit7_method_redefine</refname>
7
+
<refpurpose>Dynamically changes the code of the given method</refpurpose>
8
+
</refnamediv>
9
+

10
+
<refsect1 role="description">
11
+
&reftitle.description;
12
+
<methodsynopsis>
13
+
<type>bool</type><methodname>runkit7_method_redefine</methodname>
14
+
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
15
+
<methodparam><type>string</type><parameter>method_name</parameter></methodparam>
16
+
<methodparam><type>string</type><parameter>argument_list</parameter></methodparam>
17
+
<methodparam><type>string</type><parameter>code</parameter></methodparam>
18
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>RUNKIT7_ACC_PUBLIC</initializer></methodparam>
19
+
<methodparam choice="opt"><type>string</type><parameter>doc_comment</parameter><initializer>&null;</initializer></methodparam>
20
+
<methodparam choice="opt"><type>string</type><parameter>return_type</parameter></methodparam>
21
+
<methodparam choice="opt"><type>bool</type><parameter>is_strict</parameter></methodparam>
22
+
</methodsynopsis>
23
+
<methodsynopsis>
24
+
<type>bool</type><methodname>runkit7_method_redefine</methodname>
25
+
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
26
+
<methodparam><type>string</type><parameter>method_name</parameter></methodparam>
27
+
<methodparam><type>Closure</type><parameter>closure</parameter></methodparam>
28
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>RUNKIT7_ACC_PUBLIC</initializer></methodparam>
29
+
<methodparam choice="opt"><type>string</type><parameter>doc_comment</parameter><initializer>&null;</initializer></methodparam>
30
+
<methodparam choice="opt"><type>string</type><parameter>return_type</parameter></methodparam>
31
+
<methodparam choice="opt"><type>bool</type><parameter>is_strict</parameter></methodparam>
32
+
</methodsynopsis>
33
+
</refsect1>
34
+

35
+
<refsect1 role="parameters">
36
+
&reftitle.parameters;
37
+
<variablelist>
38
+
<varlistentry>
39
+
<term><parameter>class_name</parameter></term>
40
+
<listitem>
41
+
<para>
42
+
The class in which to redefine the method
43
+
</para>
44
+
</listitem>
45
+
</varlistentry>
46
+
<varlistentry>
47
+
<term><parameter>method_name</parameter></term>
48
+
<listitem>
49
+
<para>
50
+
The name of the method to redefine
51
+
</para>
52
+
</listitem>
53
+
</varlistentry>
54
+
<varlistentry>
55
+
<term><parameter>argument_list</parameter></term>
56
+
<listitem>
57
+
<para>
58
+
Comma-delimited list of arguments for the redefined method
59
+
</para>
60
+
</listitem>
61
+
</varlistentry>
62
+
<varlistentry>
63
+
<term><parameter>code</parameter></term>
64
+
<listitem>
65
+
<para>
66
+
The new code to be evaluated when <parameter>method_name</parameter>
67
+
is called
68
+
</para>
69
+
</listitem>
70
+
</varlistentry>
71
+
<varlistentry>
72
+
<term><parameter>closure</parameter></term>
73
+
<listitem>
74
+
<para>
75
+
A <classname>closure</classname> that defines the method.
76
+
</para>
77
+
</listitem>
78
+
</varlistentry>
79
+
<varlistentry>
80
+
<term><parameter>flags</parameter></term>
81
+
<listitem>
82
+
<para>
83
+
The redefined method can be
84
+
<constant>RUNKIT7_ACC_PUBLIC</constant>,
85
+
<constant>RUNKIT7_ACC_PROTECTED</constant> or
86
+
<constant>RUNKIT7_ACC_PRIVATE</constant> optionally combined via bitwise OR with
87
+
<constant>RUNKIT7_ACC_STATIC</constant>
88
+
</para>
89
+
</listitem>
90
+
</varlistentry>
91
+
<varlistentry>
92
+
<term><parameter>doc_comment</parameter></term>
93
+
<listitem>
94
+
<para>
95
+
The doc comment of the method.
96
+
</para>
97
+
</listitem>
98
+
</varlistentry>
99
+
<varlistentry>
100
+
<term><parameter>return_type</parameter></term>
101
+
<listitem>
102
+
<para>
103
+
The return type of the method.
104
+
</para>
105
+
</listitem>
106
+
</varlistentry>
107
+
<varlistentry>
108
+
<term><parameter>is_strict</parameter></term>
109
+
<listitem>
110
+
<para>
111
+
Whether the method behaves as if it was declared in a file with <literal>strict_types=1</literal>.
112
+
</para>
113
+
</listitem>
114
+
</varlistentry>
115
+
</variablelist>
116
+
</refsect1>
117
+

118
+
<refsect1 role="returnvalues">
119
+
&reftitle.returnvalues;
120
+
<para>
121
+
&return.success;
122
+
</para>
123
+
</refsect1>
124
+

125
+
<refsect1 role="examples">
126
+
&reftitle.examples;
127
+
<para>
128
+
<example>
129
+
<title><function>runkit7_method_redefine</function> example</title>
130
+
<programlisting role="php">
131
+
<![CDATA[
132
+
<?php
133
+
class Example {
134
+
function foo() {
135
+
return "foo!\n";
136
+
}
137
+
}
138
+

139
+
// create an Example object
140
+
$e = new Example();
141
+

142
+
// output Example::foo() (before redefine)
143
+
echo "Before: " . $e->foo();
144
+

145
+
// Redefine the 'foo' method
146
+
runkit7_method_redefine(
147
+
'Example',
148
+
'foo',
149
+
'',
150
+
'return "bar!\n";',
151
+
RUNKIT7_ACC_PUBLIC
152
+
);
153
+

154
+
// output Example::foo() (after redefine)
155
+
echo "After: " . $e->foo();
156
+
?>
157
+
]]>
158
+
</programlisting>
159
+
&example.outputs;
160
+
<screen>
161
+
<![CDATA[
162
+
Before: foo!
163
+
After: bar!
164
+
]]>
165
+
</screen>
166
+
</example>
167
+
</para>
168
+
</refsect1>
169
+
<refsect1 role="seealso">
170
+
&reftitle.seealso;
171
+
<para>
172
+
<simplelist>
173
+
<member><function>runkit7_method_add</function></member>
174
+
<member><function>runkit7_method_copy</function></member>
175
+
<member><function>runkit7_method_remove</function></member>
176
+
<member><function>runkit7_method_rename</function></member>
177
+
<member><function>runkit7_function_redefine</function></member>
178
+
</simplelist>
179
+
</para>
180
+
</refsect1>
181
+

182
+
</refentry>
183
+

184
+
<!-- Keep this comment at the end of the file
185
+
Local variables:
186
+
mode: sgml
187
+
sgml-omittag:t
188
+
sgml-shorttag:t
189
+
sgml-minimize-attributes:nil
190
+
sgml-always-quote-attributes:t
191
+
sgml-indent-step:1
192
+
sgml-indent-data:t
193
+
indent-tabs-mode:nil
194
+
sgml-parent-document:nil
195
+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
196
+
sgml-exposed-tags:nil
197
+
sgml-local-catalogs:nil
198
+
sgml-local-ecat-files:nil
199
+
End:
200
+
vim600: syn=xml fen fdm=syntax fdl=2 si
201
+
vim: et tw=78 syn=sgml
202
+
vi: ts=1 sw=1
203
+
-->
0
204