mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added RecursiveFilterIterator documentation
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@287165 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e320fa5538
commit
57e7ad3632
5 changed files with 387 additions and 2 deletions
|
@ -13,7 +13,6 @@
|
|||
<section xml:id="spl.iterators.list">
|
||||
<title>Undocumented Iterators</title>
|
||||
<simplelist>
|
||||
<member><classname>RecursiveFilterIterator</classname></member>
|
||||
<member><classname>RecursiveTreeIterator</classname></member>
|
||||
</simplelist>
|
||||
</section>
|
||||
|
@ -21,7 +20,6 @@
|
|||
</partintro>
|
||||
|
||||
<!-- TODO: Not documented
|
||||
&reference.spl.recursivefilteriterator;
|
||||
&reference.spl.recursivetreeiterator;
|
||||
-->
|
||||
|
||||
|
@ -42,6 +40,7 @@
|
|||
&reference.spl.recursivearrayiterator;
|
||||
&reference.spl.recursivecachingiterator;
|
||||
&reference.spl.recursivedirectoryiterator;
|
||||
&reference.spl.recursivefilteriterator;
|
||||
&reference.spl.recursiveiteratoriterator;
|
||||
&reference.spl.recursiveregexiterator;
|
||||
&reference.spl.regexiterator;
|
||||
|
|
94
reference/spl/recursivefilteriterator.xml
Normal file
94
reference/spl/recursivefilteriterator.xml
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: $ -->
|
||||
|
||||
<phpdoc:classref xml:id="class.recursivefilteriterator" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<title>The RecursiveFilterIterator class</title>
|
||||
<titleabbrev>RecursiveFilterIterator</titleabbrev>
|
||||
|
||||
<partintro>
|
||||
|
||||
<!-- {{{ RecursiveFilterIterator intro -->
|
||||
<section xml:id="recursivefilteriterator.intro">
|
||||
&reftitle.intro;
|
||||
<para>
|
||||
This abstract iterator filters out unwanted values for a <classname>RecursiveIterator</classname>.
|
||||
This class should be extended to implement custom filters.
|
||||
The <methodname>RecursiveFilterIterator::accept()</methodname> must be implemented in the subclass.
|
||||
</para>
|
||||
</section>
|
||||
<!-- }}} -->
|
||||
|
||||
<section xml:id="recursivefilteriterator.synopsis">
|
||||
&reftitle.classsynopsis;
|
||||
|
||||
<!-- {{{ Synopsis -->
|
||||
<classsynopsis>
|
||||
<ooclass><classname>RecursiveFilterIterator</classname></ooclass>
|
||||
|
||||
<!-- {{{ Class synopsis -->
|
||||
<classsynopsisinfo>
|
||||
<ooclass>
|
||||
<classname>RecursiveFilterIterator</classname>
|
||||
</ooclass>
|
||||
|
||||
<ooclass>
|
||||
<modifier>extends</modifier>
|
||||
<classname>FilterIterator</classname>
|
||||
</ooclass>
|
||||
|
||||
<oointerface>
|
||||
<interfacename>Iterator</interfacename>
|
||||
</oointerface>
|
||||
|
||||
<oointerface>
|
||||
<interfacename>Traversable</interfacename>
|
||||
</oointerface>
|
||||
|
||||
<oointerface>
|
||||
<interfacename>OuterIterator</interfacename>
|
||||
</oointerface>
|
||||
|
||||
<oointerface>
|
||||
<interfacename>RecursiveIterator</interfacename>
|
||||
</oointerface>
|
||||
</classsynopsisinfo>
|
||||
<!-- }}} -->
|
||||
|
||||
<classsynopsisinfo role="comment">Methods</classsynopsisinfo>
|
||||
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.recursivefilteriterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
||||
|
||||
<classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo>
|
||||
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.filteriterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
||||
|
||||
</classsynopsis>
|
||||
<!-- }}} -->
|
||||
|
||||
</section>
|
||||
|
||||
</partintro>
|
||||
|
||||
&reference.spl.entities.recursivefilteriterator;
|
||||
|
||||
</phpdoc:classref>
|
||||
|
||||
<!-- 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:"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
|
||||
-->
|
163
reference/spl/recursivefilteriterator/construct.xml
Normal file
163
reference/spl/recursivefilteriterator/construct.xml
Normal file
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: $ -->
|
||||
|
||||
<refentry xml:id="recursivefilteriterator.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>RecursiveFilterIterator::__construct</refname>
|
||||
<refpurpose>Create a RecursiveFilterIterator from a RecursiveIterator</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<methodname>RecursiveFilterIterator::__construct</methodname>
|
||||
<methodparam><type>RecursiveIterator</type><parameter>iterator</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Create a <classname>RecursiveFilterIterator</classname> from a <classname>RecursiveIterator</classname>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>iterator</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The <classname>RecursiveIterator</classname> to be filtered.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Basic <methodname>RecursiveFilterIterator</methodname> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class TestsOnlyFilter extends RecursiveFilterIterator {
|
||||
public function accept() {
|
||||
// Accept the current item if we can recurse into it
|
||||
// or it is a value starting with "test"
|
||||
return $this->hasChildren() || (strpos($this->current(), "test") !== FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
$arrary = array("test1", array("taste2", "test3", "test4"), "test5");
|
||||
$iterator = new RecursiveArrayIterator($array);
|
||||
$filter = new TestsOnlyFilter($iterator);
|
||||
|
||||
foreach(new RecursiveIteratorIterator($filter) as $key => $value)
|
||||
{
|
||||
echo $value . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
test1
|
||||
test3
|
||||
test4
|
||||
test5
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><methodname>RecursiveFilterIterator</methodname> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class StartsWithFilter extends RecursiveFilterIterator {
|
||||
|
||||
protected $word;
|
||||
|
||||
public function __construct(RecursiveIterator $rit, $word) {
|
||||
$this->word = $word;
|
||||
parent::__construct($rit);
|
||||
}
|
||||
|
||||
public function accept() {
|
||||
return $this->hasChildren() OR strpos($this->current(), $this->word) === 0;
|
||||
}
|
||||
|
||||
public function getChildren() {
|
||||
return new self($this->getInnerIterator()->getChildren(), $this->word);
|
||||
}
|
||||
}
|
||||
|
||||
$array = array("test1", array("taste2", "test3", "test4"), "test5");
|
||||
$iterator = new RecursiveArrayIterator($array);
|
||||
$filter = new StartsWithFilter($iterator, "test");
|
||||
|
||||
foreach(new RecursiveIteratorIterator($filter) as $key => $value)
|
||||
{
|
||||
echo $value . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
test1
|
||||
test3
|
||||
test4
|
||||
test5
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>RecursiveFilterIterator::getChildren</methodname></member>
|
||||
<member><methodname>RecursiveFilterIterator::hasChildren</methodname></member>
|
||||
<member><methodname>FilterIterator::accept</methodname></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:"../../../../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
|
||||
-->
|
64
reference/spl/recursivefilteriterator/getchildren.xml
Normal file
64
reference/spl/recursivefilteriterator/getchildren.xml
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: $ -->
|
||||
|
||||
<refentry xml:id="recursivefilteriterator.getchildren" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>RecursiveFilterIterator::getChildren</refname>
|
||||
<refpurpose>Return the inner iterator's children contained in a RecursiveFilterIterator</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>RecursiveFilterIterator::getChildren</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Return the inner iterator's children contained in a <classname>RecursiveFilterIterator</classname>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a <classname>RecursiveFilterIterator</classname> containing the inner iterator's children.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>RecursiveFilterIterator::hasChildren</methodname></member>
|
||||
<member><methodname>RecursiveIterator::getChildren</methodname></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:"../../../../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
|
||||
-->
|
65
reference/spl/recursivefilteriterator/haschildren.xml
Normal file
65
reference/spl/recursivefilteriterator/haschildren.xml
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: $ -->
|
||||
|
||||
<refentry xml:id="recursivefilteriterator.haschildren" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>RecursiveFilterIterator::hasChildren</refname>
|
||||
<refpurpose>Check whether the inner iterator's current element has children</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>RecursiveFilterIterator::hasChildren</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Check whether the inner iterator's current element has children.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&true; if the inner iterator has children, otherwise &false;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>RecursiveFilterIterator::getChildren</methodname></member>
|
||||
<member><methodname>RecursiveIterator::hasChildren</methodname></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:"../../../../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
|
||||
-->
|
Loading…
Reference in a new issue