mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
150 lines
3.9 KiB
XML
150 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: c6fb604f39a0fa7bf1ae872064b2a3a24f23d855 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||
<refentry xml:id="function.forward-static-call-array" xmlns="http://docbook.org/ns/docbook">
|
||
<refnamediv>
|
||
<refname>forward_static_call_array</refname>
|
||
<refpurpose>Chama um método estático e passa os argumentos como array</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<type>mixed</type><methodname>forward_static_call_array</methodname>
|
||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||
<methodparam><type>array</type><parameter>args</parameter></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Chama uma função ou método definido pelo usuário fornecido pelo parâmetro <parameter>callback</parameter>.
|
||
Esta função deve ser chamada dentro de um contexto de método, não pode ser
|
||
usada fora de uma classe.
|
||
Ela usa a <link linkend="language.oop5.late-static-bindings">ligação estática
|
||
tardia</link>.
|
||
Todos os argumentos do método encaminhado são passados como valores
|
||
e como um array, de forma semelhante a <function>call_user_func_array</function>.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>callback</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
A função ou método a ser chamado. Este parâmetro pode ser um &array;,
|
||
com o nome da classe e do método, ou uma &string;, com um nome
|
||
de função.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>args</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Um parâmetro, reunindo todos os parâmetros do método em um array.
|
||
</para>
|
||
<note>
|
||
<para>
|
||
Observe que os parâmetros para <function>forward_static_call_array</function> não
|
||
são passados por referência.
|
||
</para>
|
||
</note>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Retorna o resultado da função ou &false; em caso de erro.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<para>
|
||
<example>
|
||
<title>Exemplo de <function>forward_static_call_array</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
|
||
class A
|
||
{
|
||
const NAME = 'A';
|
||
public static function test() {
|
||
$args = func_get_args();
|
||
echo static::NAME, " ".join(',', $args)." \n";
|
||
}
|
||
}
|
||
|
||
class B extends A
|
||
{
|
||
const NAME = 'B';
|
||
|
||
public static function test() {
|
||
echo self::NAME, "\n";
|
||
forward_static_call_array(array('A', 'test'), array('mais', 'argumentos'));
|
||
forward_static_call_array( 'test', array('outros', 'argumentos'));
|
||
}
|
||
}
|
||
|
||
B::test('foo');
|
||
|
||
function test() {
|
||
$args = func_get_args();
|
||
echo "C ".join(',', $args)." \n";
|
||
}
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
B
|
||
B mais,argumentos
|
||
C outros,argumentos
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<para>
|
||
<simplelist>
|
||
<member><function>forward_static_call</function></member>
|
||
<member><function>call_user_func</function></member>
|
||
<member><function>call_user_func_array</function></member>
|
||
<member><function>is_callable</function></member>
|
||
</simplelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
</refentry>
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|