svn: /phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/ construct.xml

From: Date: Wed, 11 Jan 2012 16:47:59 +0000
Subject: svn: /phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/ construct.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9410@lists.php.net to get a copy of this message
gooh Wed, 11 Jan 2012 16:47:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=322078 Log: Added explanation for mode and flags as well as showing their effect on iteration in an example Changed paths: U phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/construct.xml Modified: phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/construct.xml =================================================================== --- phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/construct.xml 2012-01-11 16:40:05 UTC (rev 322077) +++ phpdoc/en/trunk/reference/spl/recursiveiteratoriterator/construct.xml 2012-01-11 16:47:59 UTC (rev 322078) @@ -12,15 +12,12 @@ <methodsynopsis> <modifier>public</modifier> <methodname>RecursiveIteratorIterator::__construct</methodname> <methodparam><type>Traversable</type><parameter>iterator</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>LEAVES_ONLY</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>RecursiveIteratorIterator::LEAVES_ONLY</initializer></methodparam> <methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> Creates a <classname>RecursiveIteratorIterator</classname> from a <classname>RecursiveIterator</classname>. </para> - - &warn.undocumented.func; - </refsect1> <refsect1 role="parameters"> @@ -31,7 +28,7 @@ <term><parameter>iterator</parameter></term> <listitem> <para> - The iterator being constructed from, which is from a + The iterator being constructed from. Either a <classname>RecursiveIterator</classname> or <classname>IteratorAggregate</classname>. </para> </listitem> @@ -40,8 +37,12 @@ <term><parameter>mode</parameter></term> <listitem> <para> - The mode. Options are <constant>LEAVES_ONLY</constant> (default), <constant>SELF_FIRST</constant> - and <constant>CHILD_FIRST</constant>. + Optional mode. Possible values are + <simplelist> + <listitem><constant>RecursiveIteratorIterator::LEAVES_ONLY</constant> - The default. Lists only leaves in iteration.</listitem> + <listitem><constant>RecursiveIteratorIterator::SELF_FIRST</constant> - Lists leaves and parents in iteration with parents coming first.</listitem> + <listitem><constant>RecursiveIteratorIterator::CHILD_FIRST</constant> - Lists leaves and parents in iteration with leaves coming first.</listitem> + </simplelist> </para> </listitem> </varlistentry> @@ -49,7 +50,8 @@ <term><parameter>flags</parameter></term> <listitem> <para> - + Optional flag. Possible values are <constant>RecursiveIteratorIterator::CATCH_GET_CHILD</constant> + which will then ignore exceptions thrown in calls to <method>RecursiveIteratorIterator::getChildren()</method>. </para> </listitem> </varlistentry> @@ -60,11 +62,98 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - + No value is returned. </para> </refsect1> +<refsect1 role="examples"><!-- {{{ --> +&reftitle.examples; +<para> +<example xml:id="recursiveiteratoriterator.example.basic"><!-- {{{ --> +<title>Iterating a RecursiveIteratorIterator</title> +<programlisting role="php"> +<![CDATA[ +<?php +$array = array( + array( + array( + array( + 'leaf-0-0-0-0', + 'leaf-0-0-0-1' + ), + 'leaf-0-0-0' + ), + array( + array( + 'leaf-0-1-0-0', + 'leaf-0-1-0-1' + ), + 'leaf-0-1-0' + ), + 'leaf-0-0' + ) +); + +$iterator = new RecursiveIteratorIterator( + new RecursiveArrayIterator($array), + $mode +); +foreach ($iterator as $key => $leaf) { + echo "$key => $leaf", PHP_EOL; +} +]]> +</programlisting> +<para xml:id="recursiveiteratoriterator.examples.basic.1">Output with <literal>$mode = RecursiveIteratorIterator::LEAVES_ONLY</literal></para> +<screen> +<![CDATA[ +0 => leaf-0-0-0-0 +1 => leaf-0-0-0-1 +0 => leaf-0-0-0 +0 => leaf-0-1-0-0 +1 => leaf-0-1-0-1 +0 => leaf-0-1-0 +0 => leaf-0-0 +]]> +</screen> +<para xml:id="recursiveiteratoriterator.examples.basic.2">Output with <literal>$mode = RecursiveIteratorIterator::SELF_FIRST</literal></para> +<screen> +<![CDATA[ +0 => Array +0 => Array +0 => Array +0 => leaf-0-0-0-0 +1 => leaf-0-0-0-1 +1 => leaf-0-0-0 +1 => Array +0 => Array +0 => leaf-0-1-0-0 +1 => leaf-0-1-0-1 +1 => leaf-0-1-0 +2 => leaf-0-0 +]]> +</screen> +<para xml:id="recursiveiteratoriterator.examples.basic.3">Output with <literal>$mode = RecursiveIteratorIterator::CHILD_FIRST</literal></para> +<screen> +<![CDATA[ +0 => leaf-0-0-0-0 +1 => leaf-0-0-0-1 +0 => Array +1 => leaf-0-0-0 +0 => Array +0 => leaf-0-1-0-0 +1 => leaf-0-1-0-1 +0 => Array +1 => leaf-0-1-0 +1 => Array +2 => leaf-0-0 +0 => Array +]]> +</screen> +</example><!-- }}} --> +</para> +</refsect1><!-- }}} --> + </refentry> <!-- Keep this comment at the end of the file

« previous php.doc.cvs (#9410) next »