mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@330891 c90b9560-bf6c-de11-be94-00142212c4b1
195 lines
5.2 KiB
XML
195 lines
5.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 87cd7b750894dd68e69654a11f7edb9b80d68973 Maintainer: chuso Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
|
|
<refentry xml:id="reflectionmethod.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionMethod::__construct</refname>
|
|
<refpurpose>Construye un objeto ReflectionMethod</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
|
|
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <methodname>ReflectionMethod::__construct</methodname>
|
|
<methodparam><type>string</type><parameter>class_method</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Construye un nuevo objeto de tipo <classname>ReflectionMethod</classname>.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>class</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nombre de clase u objeto (instancia de la clase) a la que pertenece el método.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nombre del método.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>class_method</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nombre de la clase y nombre del método delimitados por <literal>::</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.void;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Lnaza <classname>ReflectionException</classname> si no existiera el método.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <methodname>ReflectionMethod::__construct</methodname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class Contador
|
|
{
|
|
private static $c = 0;
|
|
|
|
/**
|
|
* Incrementar contador
|
|
*
|
|
* @final
|
|
* @static
|
|
* @access public
|
|
* @return int
|
|
*/
|
|
final public static function incrementar()
|
|
{
|
|
return ++self::$c;
|
|
}
|
|
}
|
|
|
|
// Crea una instancia de la clase ReflectionMethod
|
|
$metodo = new ReflectionMethod('Contador', 'incrementar');
|
|
|
|
// Muestra información básica
|
|
printf(
|
|
"===> El método %s%s%s%s%s%s%s '%s' (que es %s)\n" .
|
|
" declarado en %s\n" .
|
|
" líneas %d a %d\n" .
|
|
" con los modificadores %d[%s]\n",
|
|
$metodo->isInternal() ? 'interno' : 'definido por el usuario',
|
|
$metodo->isAbstract() ? ' abstract' : '',
|
|
$metodo->isFinal() ? ' final' : '',
|
|
$metodo->isPublic() ? ' public' : '',
|
|
$metodo->isPrivate() ? ' private' : '',
|
|
$metodo->isProtected() ? ' protected' : '',
|
|
$metodo->isStatic() ? ' static' : '',
|
|
$metodo->getName(),
|
|
$metodo->isConstructor() ? 'un constructor' : 'un método regular',
|
|
$metodo->getFileName(),
|
|
$metodo->getStartLine(),
|
|
$metodo->getEndline(),
|
|
$metodo->getModifiers(),
|
|
implode(' ', Reflection::getModifierNames($metodo->getModifiers()))
|
|
);
|
|
|
|
// Mostrar comentarios de documentación
|
|
printf("---> Documentación:\n %s\n", var_export($metodo->getDocComment(), 1));
|
|
|
|
// Si existieran, mostrar variables estáticas
|
|
if ($statics= $metodo->getStaticVariables()) {
|
|
printf("---> Variables estáticas: %s\n", var_export($statics, 1));
|
|
}
|
|
|
|
// Invocación del método
|
|
printf("---> Resultado de la invocación: ");
|
|
var_dump($metodo->invoke(NULL));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
===> El método definido por el usuario final public static 'incrementar' (que es un método regular)
|
|
declared in /Users/philip/cvs/phpdoc/test.php
|
|
líneas 14 a 17
|
|
con los modificadores 261[final public static]
|
|
---> Documentación:
|
|
'/**
|
|
* Incrementar contador
|
|
*
|
|
* @final
|
|
* @static
|
|
* @access public
|
|
* @return int
|
|
*/'
|
|
---> Resultado de la invocación: int(1)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>ReflectionMethod::export</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
|
|
-->
|