language/predefined/closure/bindto.xml
2a4874ed531bcc223ca4bc1b4f9a5292594abaea
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="closure.bindto" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>Closure::bindTo</refname>
...
...
@@ -11,11 +10,10 @@
11
10

12
11
<refsect1 role="description">
13
12
&reftitle.description;
14
-
<methodsynopsis>
15
-
<modifier>public</modifier> <type>Closure</type><methodname>Closure::bindTo</methodname>
16
-
<methodparam><type>object</type><parameter>newthis</parameter></methodparam>
17
-
<methodparam choice="opt"><type>mixed</type><parameter>newscope</parameter>
18
-
<initializer>"static"</initializer></methodparam>
13
+
<methodsynopsis role="Closure">
14
+
<modifier>public</modifier> <type class="union"><type>Closure</type><type>null</type></type><methodname>Closure::bindTo</methodname>
15
+
<methodparam><type class="union"><type>object</type><type>null</type></type><parameter>newThis</parameter></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>object</type><type>string</type><type>null</type></type><parameter>newScope</parameter><initializer>"static"</initializer></methodparam>
19
17
</methodsynopsis>
20
18
<para>
21
19
Create and return a new <link linkend="functions.anonymous">anonymous
...
...
@@ -29,13 +27,13 @@
29
27
which determines which private and protected members the anonymous
30
28
function will be able to access. Namely, the members that will be
31
29
visible are the same as if the anonymous function were a method of
32
-
the class given as value of the <parameter>newscope</parameter>
30
+
the class given as value of the <parameter>newScope</parameter>
33
31
parameter.
34
32
</para>
35
33

36
34
<para>
37
35
Static closures cannot have any bound object (the value of the parameter
38
-
<parameter>newthis</parameter> should be &null;), but this function can
36
+
<parameter>newThis</parameter> should be &null;), but this function can
39
37
nevertheless be used to change their class scope.
40
38
</para>
41
39

...
...
@@ -60,7 +58,7 @@
60
58
&reftitle.parameters;
61
59
<variablelist>
62
60
<varlistentry>
63
-
<term><parameter>newthis</parameter></term>
61
+
<term><parameter>newThis</parameter></term>
64
62
<listitem>
65
63
<para>
66
64
The object to which the given anonymous function should be bound, or
...
...
@@ -69,7 +67,7 @@
69
67
</listitem>
70
68
</varlistentry>
71
69
<varlistentry>
72
-
<term><parameter>newscope</parameter></term>
70
+
<term><parameter>newScope</parameter></term>
73
71
<listitem>
74
72
<para>
75
73
The class scope to which the closure is to be associated, or
...
...
@@ -87,32 +85,7 @@
87
85
&reftitle.returnvalues;
88
86
<para>
89
87
Returns the newly created <classname>Closure</classname> object
90
-
&return.falseforfailure;
91
-
</para>
92
-
</refsect1>
93
-
94
-
<refsect1 role="changelog">
95
-
&reftitle.changelog;
96
-
<para>
97
-
<informaltable>
98
-
<tgroup cols="2">
99
-
<thead>
100
-
<row>
101
-
<entry>&Version;</entry>
102
-
<entry>&Description;</entry>
103
-
</row>
104
-
</thead>
105
-
<tbody>
106
-
<row>
107
-
<entry>7.0.0</entry>
108
-
<entry>
109
-
<parameter>newscope</parameter> can not be (an object of) an internal
110
-
class anymore, what was possible prior to this version.
111
-
</entry>
112
-
</row>
113
-
</tbody>
114
-
</tgroup>
115
-
</informaltable>
88
+
or &null; on failure.
116
89
</para>
117
90
</refsect1>
118
91

...
...
@@ -124,13 +97,21 @@
124
97
<![CDATA[
125
98
<?php
126
99

127
-
class A {
128
-
function __construct($val) {
100
+
class A
101
+
{
102
+
private $val;
103
+

104
+
public function __construct($val)
105
+
{
129
106
$this->val = $val;
130
107
}
131
-
function getClosure() {
132
-
//returns closure bound to this object and scope
133
-
return function() { return $this->val; };
108
+

109
+
public function getClosure()
110
+
{
111
+
// Returns closure bound to this object and scope
112
+
return function() {
113
+
return $this->val;
114
+
};
134
115
}
135
116
}
136
117

...
...
@@ -139,8 +120,10 @@ $ob2 = new A(2);
139
120

140
121
$cl = $ob1->getClosure();
141
122
echo $cl(), "\n";
123
+

142
124
$cl = $cl->bindTo($ob2);
143
125
echo $cl(), "\n";
126
+

144
127
?>
145
128
]]>
146
129
</programlisting>
...
...
@@ -164,7 +147,6 @@ echo $cl(), "\n";
164
147
</refsect1>
165
148

166
149
</refentry>
167
-

168
150
<!-- Keep this comment at the end of the file
169
151
Local variables:
170
152
mode: sgml
171
153