|
3 | 3 | <refentry xml:id="function.forward-static-call-array" xmlns="http://docbook.org/ns/docbook"> |
4 | 4 | <refnamediv> |
5 | 5 | <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> |
7 | 8 | </refnamediv> |
8 | 9 |
|
9 | 10 | <refsect1 role="description"> |
|
13 | 14 | <methodparam><type>callable</type><parameter>callback</parameter></methodparam> |
14 | 15 | <methodparam><type>array</type><parameter>args</parameter></methodparam> |
15 | 16 | </methodsynopsis> |
16 | | - <para> |
| 17 | + <simpara> |
17 | 18 | Calls a user defined function or method given by the <parameter>callback</parameter> |
18 | 19 | parameter. This function must be called within a method context, it can't be |
19 | 20 | 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> |
25 | 30 | </refsect1> |
26 | 31 |
|
27 | 32 | <refsect1 role="parameters"> |
|
41 | 46 | <varlistentry> |
42 | 47 | <term><parameter>args</parameter></term> |
43 | 48 | <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> |
47 | 52 | <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> |
52 | 57 | </note> |
53 | 58 | </listitem> |
54 | 59 | </varlistentry> |
|
0 commit comments