svn: /phpdoc/en/trunk/language/oop5/ iterations.xml

From: Date: Tue, 27 Mar 2012 22:42:19 +0000
Subject: svn: /phpdoc/en/trunk/language/oop5/ iterations.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9962@lists.php.net to get a copy of this message
salathe Tue, 27 Mar 2012 22:42:19 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=324593 Log: rework iterator/iteratoraggregate parts of oop5.iteration (no more "you"!) Changed paths: U phpdoc/en/trunk/language/oop5/iterations.xml Modified: phpdoc/en/trunk/language/oop5/iterations.xml =================================================================== --- phpdoc/en/trunk/language/oop5/iterations.xml 2012-03-27 20:32:58 UTC (rev 324592) +++ phpdoc/en/trunk/language/oop5/iterations.xml 2012-03-27 22:42:19 UTC (rev 324593) @@ -65,14 +65,16 @@ </example> <para> - As the output shows, the &foreach; iterated through all - <link linkend="language.oop5.visibility">visible</link> variables that can be - accessed. To take it a step further you can implement one - of PHP 5's internal <link - linkend="language.oop5.interfaces">interface</link> named - <varname>Iterator</varname>. This allows the object to decide what and how - the object will be iterated. + As the output shows, the &foreach; iterated through all of the + <link linkend="language.oop5.visibility">visible</link> properties that could be + accessed. </para> + <para> + To take it a step further, the <interfacename>Iterator</interfacename> + <link linkend="language.oop5.interfaces">interface</link> may be implemented. + This allows the object to dictate how it will be iterated and what values will + be available on each iteration. + </para> <example> <title>Object Iteration implementing Iterator</title> @@ -162,9 +164,14 @@ </example> <para> - You can also define your class so that it doesn't have to define - all the <varname>Iterator</varname> functions by simply implementing - the PHP 5 <varname>IteratorAggregate</varname> interface. + The <interfacename>IteratorAggregate</interfacename> + <link linkend="language.oop5.interfaces">interface</link> + can be used as an alternative to implementing all of the + <interfacename>Iterator</interfacename> methods. + <interfacename>IteratorAggregate</interfacename> only requires the + implementation of a single method, + <methodname>IteratorAggregate::getIterator</methodname>, which should return + an instance of a class implementing <interfacename>Iterator</interfacename>. </para> <example>

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