1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 15:12:13 +01:00
Files
archived-doc-fr/reference/reflection/reflectionfunction/construct.xml
George Peter Banyard e6398deab4 Reviewed part of French Reflection doc
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@346575 c90b9560-bf6c-de11-be94-00142212c4b1
2019-01-08 05:14:01 +00:00

208 lines
4.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: d8b968e63cba67a082e6e37aee1ebe7821b41258 Maintainer: jpauli Status: ready -->
<!-- Reviewed: yes -->
<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>Construit un nouvel objet 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>
Construit un nouvel objet <classname>ReflectionFunction</classname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
Le nom de la fonction à refléter ou une
<link linkend="functions.anonymous">fermeture</link>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Une exception <classname>ReflectionException</classname> si le paramètre <parameter>name</parameter>
contient une fonction invalide.
</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>
<parameter>name</parameter> peut désormais être une
<link linkend="functions.anonymous">fonctions anonymes</link>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <methodname>ReflectionFunction::__construct</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
/**
* Un simple compteur
*
* @return int
*/
function counter1()
{
static $c = 0;
return ++$c;
}
/**
* Une autre simple compteur
*
* @return int
*/
$counter2 = function()
{
static $d = 0;
return ++$d;
};
function dumpReflectionFunction($func)
{
// Affiche des informations basiques
printf(
"\n\n===> The %s function '%s'\n".
" declared in %s\n".
" lines %d to %d\n",
$func->isInternal() ? 'internal' : 'user-defined',
$func->getName(),
$func->getFileName(),
$func->getStartLine(),
$func->getEndline()
);
// Affiche les commentaires de documentation
printf("---> Documentation:\n %s\n", var_export($func->getDocComment(), 1));
// Affiche les variables statiques existantes
if ($statics = $func->getStaticVariables())
{
printf("---> Static variables: %s\n", var_export($statics, 1));
}
}
// Créer une instance de la classe ReflectionFunction
dumpReflectionFunction(new ReflectionFunction('counter1'));
dumpReflectionFunction(new ReflectionFunction($counter2));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
===> The user-defined function 'counter1'
declared in Z:\reflectcounter.php
lines 7 to 11
---> Documentation:
'/**
* A simple counter
*
* @return int
*/'
---> Static variables: array (
'c' => 0,
)
===> The user-defined function '{closure}'
declared in Z:\reflectcounter.php
lines 18 to 23
---> Documentation:
'/**
* Another simple counter
*
* @return int
*/'
---> Static variables: 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">Les constructeurs</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
-->