Skip to content

Commit 81e7e08

Browse files
committed
Clarify forward_static_call docs
1 parent b513cbb commit 81e7e08

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

reference/funchand/functions/forward-static-call-array.xml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<refentry xml:id="function.forward-static-call-array" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
55
<refname>forward_static_call_array</refname>
6-
<refpurpose>Call a static method and pass the arguments as array</refpurpose>
6+
<refpurpose>Call a callback while preserving the current called class, with
7+
parameters as an array</refpurpose>
78
</refnamediv>
89

910
<refsect1 role="description">
@@ -17,10 +18,14 @@
1718
Calls a user defined function or method given by the <parameter>callback</parameter>
1819
parameter. This function must be called within a method context, it can't be
1920
used outside a class.
20-
It uses the <link linkend="language.oop5.late-static-bindings">late static
21-
binding</link>.
22-
All arguments of the forwarded method are passed as values,
23-
and as an array, similarly to <function>call_user_func_array</function>.
21+
When calling a method callback, it forwards the current
22+
<link linkend="language.oop5.late-static-bindings">late static binding</link>,
23+
so <literal>static::</literal> inside the method resolves to the current
24+
called class. This is useful for static method callbacks that should behave
25+
like forwarding calls such as <literal>parent::</literal> or
26+
<literal>self::</literal>.
27+
Arguments for the callback are taken from the <parameter>args</parameter>
28+
array, similarly to <function>call_user_func_array</function>.
2429
</para>
2530
</refsect1>
2631

@@ -42,12 +47,12 @@
4247
<term><parameter>args</parameter></term>
4348
<listitem>
4449
<para>
45-
One parameter, gathering all the method parameter in one array.
50+
The parameters to be passed to the callback, as an array.
4651
</para>
4752
<note>
4853
<para>
49-
Note that the parameters for <function>forward_static_call_array</function> are
50-
not passed by reference.
54+
To pass a parameter by reference, the corresponding element in
55+
<parameter>args</parameter> must be a reference.
5156
</para>
5257
</note>
5358
</listitem>

reference/funchand/functions/forward-static-call.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<refentry xml:id="function.forward-static-call" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
55
<refname>forward_static_call</refname>
6-
<refpurpose>Call a static method</refpurpose>
6+
<refpurpose>Call a callback while preserving the current called class</refpurpose>
77
</refnamediv>
88

99
<refsect1 role="description">
@@ -17,8 +17,12 @@
1717
Calls a user defined function or method given by the <parameter>callback</parameter>
1818
parameter, with the following arguments. This function must be called within a method
1919
context, it can't be used outside a class.
20-
It uses the <link linkend="language.oop5.late-static-bindings">late static
21-
binding</link>.
20+
When calling a method callback, it forwards the current
21+
<link linkend="language.oop5.late-static-bindings">late static binding</link>,
22+
so <literal>static::</literal> inside the method resolves to the current
23+
called class. This is useful for static method callbacks that should behave
24+
like forwarding calls such as <literal>parent::</literal> or
25+
<literal>self::</literal>.
2226
</para>
2327
</refsect1>
2428

@@ -40,7 +44,7 @@
4044
<term><parameter>args</parameter></term>
4145
<listitem>
4246
<para>
43-
Zero or more parameters to be passed to the function.
47+
Zero or more parameters to be passed to the callback.
4448
</para>
4549
</listitem>
4650
</varlistentry>

0 commit comments

Comments
 (0)