mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 15:32:36 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@321984 c90b9560-bf6c-de11-be94-00142212c4b1
206 lines
4.7 KiB
XML
206 lines
4.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: d8b968e63cba67a082e6e37aee1ebe7821b41258 Maintainer: chuso Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
|
|
<refentry xml:id="reflectionfunction.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionFunction::__construct</refname>
|
|
<refpurpose>Contruye un objeto de tipo ReflectionFunction</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <methodname>ReflectionFunction::__construct</methodname>
|
|
<methodparam><type>mixed</type><parameter>name</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Construye un objeto de tipo <classname>ReflectionFunction</classname>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nombre de la función que se desea reflexionar, o una <link linkend="functions.anonymous">función anónima</link>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.void;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Lanza <classname>ReflectionException</classname> si el parámetro <parameter>name</parameter>
|
|
no contuviera una función válida.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.3.0</entry>
|
|
<entry>
|
|
ahora <parameter>name</parameter> puede representar una <link linkend="functions.anonymous">función anónima</link>.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <methodname>ReflectionFunction::__construct</methodname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/**
|
|
* Contador sencillo
|
|
*
|
|
* @return int
|
|
*/
|
|
function contador1()
|
|
{
|
|
static $c = 0;
|
|
return ++$c;
|
|
}
|
|
|
|
/**
|
|
* Otro contador sencillo
|
|
*
|
|
* @return int
|
|
*/
|
|
$contador2 = function()
|
|
{
|
|
static $d = 0;
|
|
return ++$d;
|
|
|
|
};
|
|
|
|
function mostrarFuncionesReflexionadas($func)
|
|
{
|
|
// Mostrar información básica
|
|
printf(
|
|
"\n\n===> La función %s '%s'\n".
|
|
" declarada en %s\n".
|
|
" líneas %d a %d\n",
|
|
$func->isInternal() ? 'interna' : 'definida por el usuario',
|
|
$func->getName(),
|
|
$func->getFileName(),
|
|
$func->getStartLine(),
|
|
$func->getEndline()
|
|
);
|
|
|
|
// Mostrar comentarios de documentación
|
|
printf("---> Documentación:\n %s\n", var_export($func->getDocComment(), 1));
|
|
|
|
// Mostrar, si existen, variables estáticas
|
|
if ($statics = $func->getStaticVariables())
|
|
{
|
|
printf("---> Variables estáticas: %s\n", var_export($statics, 1));
|
|
}
|
|
}
|
|
|
|
// Crear una instancia de la clase ReflectionFunction
|
|
mostrarFuncionesReflexionadas(new ReflectionFunction('contador1'));
|
|
mostrarFuncionesReflexionadas(new ReflectionFunction($contador2));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
===> La función definida por el usuario 'contador1'
|
|
declarada en /Users/chuso/dropme.php
|
|
líneas 7 a 11
|
|
---> Documentación:
|
|
'/**
|
|
* Contador sencillo
|
|
*
|
|
* @return int
|
|
*/'
|
|
---> Variables estáticas: array (
|
|
'c' => 0,
|
|
)
|
|
|
|
|
|
===> La función definida por el usuario '{closure}'
|
|
declarada en /Users/chuso/dropme.php
|
|
líneas 18 a 23
|
|
---> Documentación:
|
|
'/**
|
|
* Otro contador sencillo
|
|
*
|
|
* @return int
|
|
*/'
|
|
---> Variables estáticas: array (
|
|
'd' => 0,
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>ReflectionMethod::__construct</methodname></member>
|
|
<member><link linkend="language.oop5.decon.constructor">Constructores</link></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
|
|
-->
|