language/oop5/overloading.xml
2ab7e9d763666526942ed4477c4f876beb160892
...
...
@@ -35,53 +35,13 @@
35
35
<note>
36
36
<para>
37
37
PHP's interpretation of <quote>overloading</quote> is
38
-
different than most object oriented languages. Overloading
38
+
different than most object-oriented languages. Overloading
39
39
traditionally provides the ability to have multiple methods
40
40
with the same name but different quantities and types of
41
41
arguments.
42
42
</para>
43
43
</note>
44
44

45
-

46
-
<sect2 xml:id="language.oop5.overloading.changelog">
47
-
&reftitle.changelog;
48
-
<para>
49
-
<informaltable>
50
-
<tgroup cols="2">
51
-
<thead>
52
-
<row>
53
-
<entry>&Version;</entry>
54
-
<entry>&Description;</entry>
55
-
</row>
56
-
</thead>
57
-
<tbody>
58
-
<row>
59
-
<entry>5.3.0</entry>
60
-
<entry>
61
-
Added <link linkend="object.callstatic">__callStatic()</link>.
62
-
Added warning to enforce public visibility and non-static declaration.
63
-
</entry>
64
-
</row>
65
-
<row>
66
-
<entry>5.1.0</entry>
67
-
<entry>
68
-
Added <link linkend="object.isset">__isset()</link> and <link linkend="object.unset">__unset()</link>.
69
-
Added support for <link linkend="object.get">__get()</link> for overloading of private properties.
70
-
</entry>
71
-
</row>
72
-
<row>
73
-
<entry>5.0.0</entry>
74
-
<entry>
75
-
Added <link linkend="object.get">__get()</link>.
76
-
</entry>
77
-
</row>
78
-
</tbody>
79
-
</tgroup>
80
-
</informaltable>
81
-
</para>
82
-
</sect2>
83
-

84
-

85
45
<sect2 xml:id="language.oop5.overloading.members">
86
46
<title>Property overloading</title>
87
47

...
...
@@ -137,8 +97,8 @@
137
97
Property overloading only works in object context. These magic
138
98
methods will not be triggered in static context. Therefore
139
99
these methods should not be declared
140
-
<link linkend="language.oop5.static">static</link>. As of PHP
141
-
5.3.0, a warning is issued if one of the magic overloading
100
+
<link linkend="language.oop5.static">static</link>.
101
+
A warning is issued if one of the magic overloading
142
102
methods is declared <literal>static</literal>.
143
103
</para>
144
104

...
...
@@ -152,6 +112,18 @@
152
112
</para>
153
113
</note>
154
114

115
+
<note>
116
+
<para>
117
+
PHP will not call an overloaded method from within the same overloaded method.
118
+
That means, for example, writing <code>return $this->foo</code> inside of
119
+
<link linkend="object.get">__get()</link> will return <literal>null</literal>
120
+
and raise an <constant>E_WARNING</constant> if there is no <literal>foo</literal> property defined,
121
+
rather than calling <link linkend="object.get">__get()</link> a second time.
122
+
However, overload methods may invoke other overload methods implicitly (such as
123
+
<link linkend="object.set">__set()</link> triggering <link linkend="object.get">__get()</link>).
124
+
</para>
125
+
</note>
126
+

155
127
<example>
156
128
<title>
157
129
Overloading properties via the <link linkend="object.get">__get()</link>,
...
...
@@ -194,14 +166,12 @@ class PropertyTest
194
166
return null;
195
167
}
196
168

197
-
/** As of PHP 5.1.0 */
198
169
public function __isset($name)
199
170
{
200
171
echo "Is '$name' set?\n";
201
172
return isset($this->data[$name]);
202
173
}
203
174

204
-
/** As of PHP 5.1.0 */
205
175
public function __unset($name)
206
176
{
207
177
echo "Unsetting '$name'\n";
...
...
@@ -315,7 +285,6 @@ class MethodTest
315
285
. implode(', ', $arguments). "\n";
316
286
}
317
287

318
-
/** As of PHP 5.3.0 */
319
288
public static function __callStatic($name, $arguments)
320
289
{
321
290
// Note: value of $name is case sensitive.
...
...
@@ -327,7 +296,7 @@ class MethodTest
327
296
$obj = new MethodTest;
328
297
$obj->runTest('in object context');
329
298

330
-
MethodTest::runTest('in static context'); // As of PHP 5.3.0
299
+
MethodTest::runTest('in static context');
331
300
?>
332
301
]]>
333
302
</programlisting>
...
...
@@ -343,7 +312,6 @@ Calling static method 'runTest' in static context
343
312
</sect2>
344
313

345
314
</sect1>
346
-

347
315
<!-- Keep this comment at the end of the file
348
316
Local variables:
349
317
mode: sgml
350
318