Skip to content

Commit 64c183f

Browse files
committed
Clarify forward_static_call docs
1 parent b513cbb commit 64c183f

2 files changed

Lines changed: 31 additions & 22 deletions

File tree

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

Lines changed: 19 additions & 14 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">
@@ -13,15 +14,19 @@
1314
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
1415
<methodparam><type>array</type><parameter>args</parameter></methodparam>
1516
</methodsynopsis>
16-
<para>
17+
<simpara>
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>.
24-
</para>
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>.
29+
</simpara>
2530
</refsect1>
2631

2732
<refsect1 role="parameters">
@@ -41,14 +46,14 @@
4146
<varlistentry>
4247
<term><parameter>args</parameter></term>
4348
<listitem>
44-
<para>
45-
One parameter, gathering all the method parameter in one array.
46-
</para>
49+
<simpara>
50+
The parameters to be passed to the callback, as an array.
51+
</simpara>
4752
<note>
48-
<para>
49-
Note that the parameters for <function>forward_static_call_array</function> are
50-
not passed by reference.
51-
</para>
53+
<simpara>
54+
To pass a parameter by reference, the corresponding element in
55+
<parameter>args</parameter> must be a reference.
56+
</simpara>
5257
</note>
5358
</listitem>
5459
</varlistentry>

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

Lines changed: 12 additions & 8 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">
@@ -13,13 +13,17 @@
1313
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
1414
<methodparam rep="repeat"><type>mixed</type><parameter>args</parameter></methodparam>
1515
</methodsynopsis>
16-
<para>
16+
<simpara>
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>.
22-
</para>
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>.
26+
</simpara>
2327
</refsect1>
2428

2529
<refsect1 role="parameters">
@@ -39,9 +43,9 @@
3943
<varlistentry>
4044
<term><parameter>args</parameter></term>
4145
<listitem>
42-
<para>
43-
Zero or more parameters to be passed to the function.
44-
</para>
46+
<simpara>
47+
Zero or more parameters to be passed to the callback.
48+
</simpara>
4549
</listitem>
4650
</varlistentry>
4751
</variablelist>

0 commit comments

Comments
 (0)