<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionclass.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'reflectionclass.isiterable.php',
    1 => 'ReflectionClass::isIterable',
    2 => 'V&eacute;rifie si cette classe est it&eacute;rable',
  ),
  'up' => 
  array (
    0 => 'class.reflectionclass.php',
    1 => 'ReflectionClass',
  ),
  'prev' => 
  array (
    0 => 'reflectionclass.isinternal.php',
    1 => 'ReflectionClass::isInternal',
  ),
  'next' => 
  array (
    0 => 'reflectionclass.isiterateable.php',
    1 => 'ReflectionClass::isIterateable',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/reflection/reflectionclass/isiterable.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionclass.isiterable" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::isIterable</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::isIterable</span> &mdash; <span class="dc-title">Vérifie si cette classe est itérable</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.isiterable-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::isIterable</strong></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Vérifie si cette classe est itérable (c&#039;est-à-dire qu&#039;elle peut être utilisée dans <a href="control-structures.foreach.php" class="link"><code class="literal">foreach</code></a>).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.isiterable-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-reflectionclass.isiterable-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Renvoie <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> si la classe est itérable ou sinon <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.isiterable-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Utilisation simple de <span class="methodname"><strong>ReflectionClass::isIterable()</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 /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">IteratorClass </span><span style="color: #007700">implements </span><span style="color: #0000BB">Iterator<br /></span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">__construct</span><span style="color: #007700">() {}<br /><br />    public function </span><span style="color: #0000BB">key</span><span style="color: #007700">(): </span><span style="color: #0000BB">mixed </span><span style="color: #007700">{}<br /><br />    public function </span><span style="color: #0000BB">current</span><span style="color: #007700">(): </span><span style="color: #0000BB">mixed </span><span style="color: #007700">{}<br /><br />    public function </span><span style="color: #0000BB">next</span><span style="color: #007700">(): </span><span style="color: #0000BB">void </span><span style="color: #007700">{}<br /><br />    public function </span><span style="color: #0000BB">valid</span><span style="color: #007700">(): </span><span style="color: #0000BB">bool </span><span style="color: #007700">{}<br /><br />    public function </span><span style="color: #0000BB">rewind</span><span style="color: #007700">(): </span><span style="color: #0000BB">void </span><span style="color: #007700">{}<br />}<br /><br />class </span><span style="color: #0000BB">DerivedClass </span><span style="color: #007700">extends </span><span style="color: #0000BB">IteratorClass </span><span style="color: #007700">{}<br /><br />class </span><span style="color: #0000BB">NonIterator </span><span style="color: #007700">{}<br /><br />function </span><span style="color: #0000BB">dump_iterable</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">)<br />{<br />    </span><span style="color: #0000BB">$reflection </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isIterable</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #0000BB">$classes </span><span style="color: #007700">= [</span><span style="color: #DD0000">"ArrayObject"</span><span style="color: #007700">, </span><span style="color: #DD0000">"IteratorClass"</span><span style="color: #007700">, </span><span style="color: #DD0000">"DerivedClass"</span><span style="color: #007700">, </span><span style="color: #DD0000">"NonIterator"</span><span style="color: #007700">,];<br /><br />foreach (</span><span style="color: #0000BB">$classes </span><span style="color: #007700">as </span><span style="color: #0000BB">$class</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Est ce que </span><span style="color: #0000BB">$class</span><span style="color: #DD0000"> est itérable ? "</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">dump_iterable</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">);<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">Est ce que ArrayObject est itérable ? bool(true)
Est ce que IteratorClass est itérable ? bool(true)
Est ce que DerivedClass est itérable ? bool(true)
Est ce que NonIterator est itérable ? bool(false)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.isiterable-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionclass.construct.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::__construct()</a> - Construit une ReflectionClass</span></li>
   </ul>
  </p>
 </div>


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