<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionfunction.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'reflectionfunction.construct.php',
    1 => 'ReflectionFunction::__construct',
    2 => 'Construit un nouvel objet ReflectionFunction',
  ),
  'up' => 
  array (
    0 => 'class.reflectionfunction.php',
    1 => 'ReflectionFunction',
  ),
  'prev' => 
  array (
    0 => 'class.reflectionfunction.php',
    1 => 'ReflectionFunction',
  ),
  'next' => 
  array (
    0 => 'reflectionfunction.export.php',
    1 => 'ReflectionFunction::export',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/reflection/reflectionfunction/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionfunction.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionFunction::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionFunction::__construct</span> &mdash; <span class="dc-title">Construit un nouvel objet ReflectionFunction</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionfunction.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionFunction::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.closure.php" class="type Closure">Closure</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$function</code></span>)</div>

  <p class="para rdfs-comment">
   Construit un nouvel objet <span class="classname"><a href="class.reflectionfunction.php" class="classname">ReflectionFunction</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionfunction.construct-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">function</code></dt>
     <dd>
      <p class="para">
       Le nom de la fonction à refléter ou une
       <a href="functions.anonymous.php" class="link">fermeture</a>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionfunction.construct-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Une exception <span class="classname"><a href="class.reflectionexception.php" class="classname">ReflectionException</a></span> si le paramètre <code class="parameter">function</code>
   contient une fonction invalide.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionfunction.construct-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="methodname"><strong>ReflectionFunction::__construct()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br /> * Un simple compteur<br /> *<br /> * @return    int<br /> */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">counter1</span><span style="color: #007700">()<br />{<br />    static </span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />    return ++</span><span style="color: #0000BB">$c</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">/**<br /> * Un autre simple compteur<br /> *<br /> * @return    int<br /> */<br /></span><span style="color: #0000BB">$counter2 </span><span style="color: #007700">= function()<br />{<br />    static </span><span style="color: #0000BB">$d </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />    return ++</span><span style="color: #0000BB">$d</span><span style="color: #007700">;<br /><br />};<br /><br />function </span><span style="color: #0000BB">dumpReflectionFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">$func</span><span style="color: #007700">)<br />{<br />    </span><span style="color: #FF8000">// Affiche des informations basiques<br />    </span><span style="color: #0000BB">printf</span><span style="color: #007700">(<br />        </span><span style="color: #DD0000">"\n\n===&gt; The %s function '%s'\n"</span><span style="color: #007700">.<br />        </span><span style="color: #DD0000">"     declared in %s\n"</span><span style="color: #007700">.<br />        </span><span style="color: #DD0000">"     lines %d to %d\n"</span><span style="color: #007700">,<br />        </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isInternal</span><span style="color: #007700">() ? </span><span style="color: #DD0000">'internal' </span><span style="color: #007700">: </span><span style="color: #DD0000">'user-defined'</span><span style="color: #007700">,<br />        </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">(),<br />        </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getFileName</span><span style="color: #007700">(),<br />        </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getStartLine</span><span style="color: #007700">(),<br />        </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getEndline</span><span style="color: #007700">()<br />    );<br /><br />    </span><span style="color: #FF8000">// Affiche les commentaires de documentation<br />    </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"---&gt; Documentation:\n %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getDocComment</span><span style="color: #007700">(), </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br />    </span><span style="color: #FF8000">// Affiche les variables statiques existantes<br />    </span><span style="color: #007700">if (</span><span style="color: #0000BB">$statics </span><span style="color: #007700">= </span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getStaticVariables</span><span style="color: #007700">())<br />    {<br />        </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"---&gt; Static variables: %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$statics</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br />    }<br />}<br /><br /></span><span style="color: #FF8000">// Créer une instance de la classe ReflectionFunction<br /></span><span style="color: #0000BB">dumpReflectionFunction</span><span style="color: #007700">(new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter1'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">dumpReflectionFunction</span><span style="color: #007700">(new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">$counter2</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">===&gt; The user-defined function &#039;counter1&#039;
     declared in Z:\reflectcounter.php
     lines 7 to 11
---&gt; Documentation:
 &#039;/**
 * Un simple compteur
 *
 * @return    int
 */&#039;
---&gt; Static variables: array (
  &#039;c&#039; =&gt; 0,
)


===&gt; The user-defined function &#039;{closure}&#039;
     declared in Z:\reflectcounter.php
     lines 18 to 23
---&gt; Documentation:
 &#039;/**
 * Un autre simple compteur
 *
 * @return    int
 */&#039;
---&gt; Static variables: array (
  &#039;d&#039; =&gt; 0,
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionfunction.construct-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionmethod.construct.php" class="methodname" rel="rdfs-seeAlso">ReflectionMethod::__construct()</a> - Construit un nouvel objet ReflectionMethod</span></li>
    <li><a href="language.oop5.decon.php#language.oop5.decon.constructor" class="link">Les constructeurs</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>