Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions reference/funchand/functions/forward-static-call-array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<refentry xml:id="function.forward-static-call-array" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>forward_static_call_array</refname>
<refpurpose>Call a static method and pass the arguments as array</refpurpose>
<refpurpose>Call a callback with an array of parameters, preserving the
current called class</refpurpose>
</refnamediv>

<refsect1 role="description">
Expand All @@ -17,10 +18,12 @@
Calls a user defined function or method given by the <parameter>callback</parameter>
parameter, with arguments passed as an array, similarly to
<function>call_user_func_array</function>.
When called from within a method context, it uses the
<link linkend="language.oop5.late-static-bindings">late static binding</link>.
When called outside a class context, it behaves like
<function>call_user_func_array</function>, without late static binding.
When called from within a method context and calling a method callback,
it makes a
<link linkend="language.oop5.late-static-bindings">forwarding call</link>,
so <literal>static::</literal> inside the method resolves to the same called
class as in the caller. This is useful for static method callbacks that
should behave like <literal>self::</literal> or <literal>parent::</literal>.
</simpara>
<note>
<simpara>
Expand Down Expand Up @@ -49,14 +52,14 @@
<varlistentry>
<term><parameter>args</parameter></term>
<listitem>
<para>
One parameter, gathering all the method parameter in one array.
</para>
<simpara>
The parameters to be passed to the callback, as an array.
</simpara>
<note>
<para>
Note that the parameters for <function>forward_static_call_array</function> are
not passed by reference.
</para>
<simpara>
To pass a parameter by reference, the corresponding element in
<parameter>args</parameter> must be a reference.
</simpara>
</note>
</listitem>
</varlistentry>
Expand Down
19 changes: 11 additions & 8 deletions reference/funchand/functions/forward-static-call.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<refentry xml:id="function.forward-static-call" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>forward_static_call</refname>
<refpurpose>Call a static method</refpurpose>
<refpurpose>Call a callback while preserving the current called class</refpurpose>
</refnamediv>

<refsect1 role="description">
Expand All @@ -13,13 +13,16 @@
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>args</parameter></methodparam>
</methodsynopsis>
<para>
<simpara>
Calls a user defined function or method given by the <parameter>callback</parameter>
parameter, with the following arguments. This function must be called within a method
context, it can't be used outside a class.
It uses the <link linkend="language.oop5.late-static-bindings">late static
binding</link>.
</para>
When calling a method callback, it makes a
<link linkend="language.oop5.late-static-bindings">forwarding call</link>,
so <literal>static::</literal> inside the method resolves to the same called
class as in the caller. This is useful for static method callbacks that
should behave like <literal>self::</literal> or <literal>parent::</literal>.
</simpara>
</refsect1>

<refsect1 role="parameters">
Expand All @@ -39,9 +42,9 @@
<varlistentry>
<term><parameter>args</parameter></term>
<listitem>
<para>
Zero or more parameters to be passed to the function.
</para>
<simpara>
Zero or more parameters to be passed to the callback.
</simpara>
</listitem>
</varlistentry>
</variablelist>
Expand Down