<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionfunctionabstract.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'reflectionfunctionabstract.getclosurecalledclass.php',
    1 => 'ReflectionFunctionAbstract::getClosureCalledClass',
    2 => 'Renvoie la classe correspondant &agrave; static:: &agrave; l\'int&eacute;rieur d\'une fermeture',
  ),
  'up' => 
  array (
    0 => 'class.reflectionfunctionabstract.php',
    1 => 'ReflectionFunctionAbstract',
  ),
  'prev' => 
  array (
    0 => 'reflectionfunctionabstract.getattributes.php',
    1 => 'ReflectionFunctionAbstract::getAttributes',
  ),
  'next' => 
  array (
    0 => 'reflectionfunctionabstract.getclosurescopeclass.php',
    1 => 'ReflectionFunctionAbstract::getClosureScopeClass',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/reflection/reflectionfunctionabstract/getclosurecalledclass.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionfunctionabstract.getclosurecalledclass" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionFunctionAbstract::getClosureCalledClass</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.0.23, PHP 8 &gt;= 8.1.11)</p><p class="refpurpose"><span class="refname">ReflectionFunctionAbstract::getClosureCalledClass</span> &mdash; <span class="dc-title">Renvoie la classe correspondant à static:: à l&#039;intérieur d&#039;une fermeture</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionfunctionabstract.getclosurecalledclass-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionFunctionAbstract::getClosureCalledClass</strong></span>(): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.reflectionclass.php" class="type ReflectionClass">ReflectionClass</a></span></span></div>

  <p class="simpara">
   Renvoie la classe en tant que <span class="classname"><a href="class.reflectionclass.php" class="classname">ReflectionClass</a></span> qui
   correspond à la résolution du nom de la classe correspondant à <code class="literal">static::</code> à l&#039;intérieur de la
   <span class="classname"><a href="class.closure.php" class="classname">Closure</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionfunctionabstract.getclosurecalledclass-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">Cette fonction ne contient aucun paramètre.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionfunctionabstract.getclosurecalledclass-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Renvoie une <span class="classname"><a href="class.reflectionclass.php" class="classname">ReflectionClass</a></span> correspondant à la classe
   représentée par <code class="literal">static::</code> dans la <span class="classname"><a href="class.closure.php" class="classname">Closure</a></span>.
   Si la fonction n&#039;est pas une fermeture ou si elle a une portée globale, <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>
   est renvoyé à la place.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionfunctionabstract.getclosurecalledclass-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 
    Exemple illustrant la différence entre
    <span class="methodname"><strong>ReflectionFunctionAbstract::getClosureCalledClass()</strong></span>,
    <span class="methodname"><a href="reflectionfunctionabstract.getclosurescopeclass.php" class="methodname">ReflectionFunctionAbstract::getClosureScopeClass()</a></span>,
    et <span class="methodname"><a href="reflectionfunctionabstract.getclosurethis.php" class="methodname">ReflectionFunctionAbstract::getClosureThis()</a></span>
    avec une fermeture dans le contexte de l&#039;objet
   </strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">A<br /></span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">getClosure</span><span style="color: #007700">()<br />    {<br />        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">self</span><span style="color: #007700">::class, static::class);<br />        return function () {};<br />    }<br />}<br /><br />class </span><span style="color: #0000BB">B </span><span style="color: #007700">extends </span><span style="color: #0000BB">A </span><span style="color: #007700">{}<br /><br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= new </span><span style="color: #0000BB">B</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">$b</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosure</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureThis</span><span style="color: #007700">()); </span><span style="color: #FF8000">// $this === $b, car une fermeture non statique prend le contexte de l'objet<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureScopeClass</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Correspond à la résolution de self::class à l'intérieur d'une fermeture<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureCalledClass</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Correspond à la résolution de static::class à l'intérieur d'une fermeture<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">string(1) &quot;A&quot;
string(1) &quot;B&quot;
object(B)#1 (0) {
}
object(ReflectionClass)#4 (1) {
  [&quot;name&quot;]=&gt;
  string(1) &quot;A&quot;
}
object(ReflectionClass)#4 (1) {
  [&quot;name&quot;]=&gt;
  string(1) &quot;B&quot;
}</pre>
</div>
   </div>
  </div>
  <div class="example" id="example-2">
   <p><strong>Exemple #2 
    Exemple illustrant la différence entre
    <span class="methodname"><strong>ReflectionFunctionAbstract::getClosureCalledClass()</strong></span>,
    <span class="methodname"><a href="reflectionfunctionabstract.getclosurescopeclass.php" class="methodname">ReflectionFunctionAbstract::getClosureScopeClass()</a></span>,
    et <span class="methodname"><a href="reflectionfunctionabstract.getclosurethis.php" class="methodname">ReflectionFunctionAbstract::getClosureThis()</a></span>
    avec une fermeture statique sans contexte d&#039;objet
   </strong></p>
   <div class="example-contents">
    <div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">A<br /></span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">getClosure</span><span style="color: #007700">()<br />    {<br />        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">self</span><span style="color: #007700">::class, static::class);<br />        return static function () {};<br />    }<br />}<br /><br />class </span><span style="color: #0000BB">B </span><span style="color: #007700">extends </span><span style="color: #0000BB">A </span><span style="color: #007700">{}<br /><br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= new </span><span style="color: #0000BB">B</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">$b</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosure</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureThis</span><span style="color: #007700">()); </span><span style="color: #FF8000">// NULL, car la pseudo-variable $this n'est pas disponible dans un contexte statique<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureScopeClass</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Correspond à la résolution de self::class à l'intérieur d'une fermeture<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getClosureCalledClass</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Correspond à la résolution de static::class à l'intérieur d'une fermeture<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">string(1) &quot;A&quot;
string(1) &quot;B&quot;
NULL
object(ReflectionClass)#4 (1) {
  [&quot;name&quot;]=&gt;
  string(1) &quot;A&quot;
}
object(ReflectionClass)#4 (1) {
  [&quot;name&quot;]=&gt;
  string(1) &quot;B&quot;
}</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionfunctionabstract.getclosurecalledclass-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="reflectionfunctionabstract.getclosurescopeclass.php" class="methodname" rel="rdfs-seeAlso">ReflectionFunctionAbstract::getClosureScopeClass()</a> - Retourne la classe correspondant au contexte interne d'une fermeture</span></li>
   <li><span class="methodname"><a href="reflectionfunctionabstract.getclosurethis.php" class="methodname" rel="rdfs-seeAlso">ReflectionFunctionAbstract::getClosureThis()</a> - Retourne l'objet qui correspond &agrave; $this &agrave; l'int&eacute;rieur d'une closure</span></li>
   <li><a href="language.oop5.late-static-bindings.php" class="xref">Late Static Bindings (R&eacute;solution statique &agrave; la vol&eacute;e)</a></li>
  </ul>
 </div>


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