mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Initial commit
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@269006 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
44df83211c
commit
8885e155ed
6 changed files with 465 additions and 0 deletions
166
language/predefined/iterator.xml
Normal file
166
language/predefined/iterator.xml
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<phpdoc:classref xml:id="class.iterator" 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 Iterator interface</title>
|
||||
<titleabbrev>Iterator</titleabbrev>
|
||||
|
||||
<partintro>
|
||||
|
||||
<!-- {{{ Iterator intro -->
|
||||
<section xml:id="iterator.intro">
|
||||
&reftitle.intro;
|
||||
<para>
|
||||
Interface for external iterators or objects that can be iterated
|
||||
themselves internally.
|
||||
</para>
|
||||
</section>
|
||||
<!-- }}} -->
|
||||
|
||||
<section xml:id="iterator.synopsis">
|
||||
&reftitle.classsynopsis;
|
||||
|
||||
<!-- {{{ Synopsis -->
|
||||
<classsynopsis>
|
||||
<ooclass><classname>Iterator</classname></ooclass>
|
||||
|
||||
<!-- {{{ Class synopsis -->
|
||||
<classsynopsisinfo>
|
||||
<ooclass>
|
||||
<classname>Iterator</classname>
|
||||
</ooclass>
|
||||
|
||||
<oointerface>
|
||||
<interfacename>Traversable</interfacename>
|
||||
</oointerface>
|
||||
</classsynopsisinfo>
|
||||
<!-- }}} -->
|
||||
|
||||
<classsynopsisinfo role="comment">Methods</classsynopsisinfo>
|
||||
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.iterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
||||
</classsynopsis>
|
||||
<!-- }}} -->
|
||||
|
||||
</section>
|
||||
|
||||
<section xml:id="iterator.examples">
|
||||
<example xml:id="iterator.example.basic"><!-- {{{ -->
|
||||
<title>Basic usage</title>
|
||||
<para>
|
||||
This example demonstrates in which order methods are called when
|
||||
<function>foreach</function>ing over an iterator.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class myIterator implements Iterator {
|
||||
private $position = 0;
|
||||
private $array = array(
|
||||
"firstelement",
|
||||
"secondelement",
|
||||
"lastelement",
|
||||
);
|
||||
|
||||
public function __construct() {
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
function rewind() {
|
||||
var_dump(__METHOD__);
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
function current() {
|
||||
var_dump(__METHOD__);
|
||||
return $this->array[$this->position];
|
||||
}
|
||||
|
||||
function key() {
|
||||
var_dump(__METHOD__);
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
function next() {
|
||||
var_dump(__METHOD__);
|
||||
++$this->position;
|
||||
}
|
||||
|
||||
function valid() {
|
||||
var_dump(__METHOD__);
|
||||
return isset($this->array[$this->position]);
|
||||
}
|
||||
}
|
||||
|
||||
$it = new myIterator;
|
||||
|
||||
foreach($it as $key => $value) {
|
||||
var_dump($key, $value);
|
||||
echo "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(18) "myIterator::rewind"
|
||||
string(17) "myIterator::valid"
|
||||
string(19) "myIterator::current"
|
||||
string(15) "myIterator::key"
|
||||
int(0)
|
||||
string(12) "firstelement"
|
||||
|
||||
string(16) "myIterator::next"
|
||||
string(17) "myIterator::valid"
|
||||
string(19) "myIterator::current"
|
||||
string(15) "myIterator::key"
|
||||
int(1)
|
||||
string(13) "secondelement"
|
||||
|
||||
string(16) "myIterator::next"
|
||||
string(17) "myIterator::valid"
|
||||
string(19) "myIterator::current"
|
||||
string(15) "myIterator::key"
|
||||
int(2)
|
||||
string(11) "lastelement"
|
||||
|
||||
string(16) "myIterator::next"
|
||||
string(17) "myIterator::valid"
|
||||
]]>
|
||||
</screen>
|
||||
</example><!-- }}} -->
|
||||
</section>
|
||||
|
||||
|
||||
</partintro>
|
||||
|
||||
&language.predefined.iterator.current;
|
||||
&language.predefined.iterator.key;
|
||||
&language.predefined.iterator.next;
|
||||
&language.predefined.iterator.rewind;
|
||||
&language.predefined.iterator.valid;
|
||||
|
||||
</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
|
||||
-->
|
||||
|
55
language/predefined/iterator/current.xml
Normal file
55
language/predefined/iterator/current.xml
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<refentry xml:id="iterator.current" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Iterator::current</refname>
|
||||
<refpurpose>Return the current element.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>mixed</type><methodname>Iterator::current</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the current element.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Can return any type.
|
||||
</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
|
||||
-->
|
||||
|
63
language/predefined/iterator/key.xml
Normal file
63
language/predefined/iterator/key.xml
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<refentry xml:id="iterator.key" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Iterator::key</refname>
|
||||
<refpurpose>Return the key of the current element.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>scalar</type><methodname>Iterator::key</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the key of the current element.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns <type>scalar</type> on success, <type>integer</type>
|
||||
<literal>0</literal> on failure.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors"><!-- {{{ -->
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
Issues <constant>E_WARNING</constant> on failure.
|
||||
</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
|
||||
-->
|
||||
|
61
language/predefined/iterator/next.xml
Normal file
61
language/predefined/iterator/next.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<refentry xml:id="iterator.next" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Iterator::next</refname>
|
||||
<refpurpose>Move forward to next element.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>void</type><methodname>Iterator::next</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Moves the current position to the next element.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
This method is called <emphasis>after</emphasis> each
|
||||
<function>foreach</function> loop.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Any returned value is ignored.
|
||||
</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
|
||||
-->
|
||||
|
62
language/predefined/iterator/rewind.xml
Normal file
62
language/predefined/iterator/rewind.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<refentry xml:id="iterator.rewind" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Iterator::rewind</refname>
|
||||
<refpurpose>Rewind the Iterator to the first element.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>void</type><methodname>Iterator::rewind</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Rewinds back to the first element of the Iterator.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
This is the <emphasis>first</emphasis> method called when starting a
|
||||
<function>foreach</function> loop. It will <emphasis>not</emphasis> be
|
||||
executed <emphasis>after</emphasis> <function>foreach</function> loops.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Any returned value is ignored.
|
||||
</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
|
||||
-->
|
||||
|
58
language/predefined/iterator/valid.xml
Normal file
58
language/predefined/iterator/valid.xml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
|
||||
<refentry xml:id="iterator.valid" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Iterator::valid</refname>
|
||||
<refpurpose>Checks if current position is valid.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>boolean</type><methodname>Iterator::valid</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
This method is called after <methodname>Iterator::rewind</methodname> and
|
||||
<methodname>Iterator::next</methodname> to check if the current position is
|
||||
valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The return value will be casted to <type>boolean</type> and then evaluated.
|
||||
&return.success;
|
||||
</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