From f130f1800e609998604dbe50278a69879ba6c01f Mon Sep 17 00:00:00 2001 From: Peter Cowburn Date: Tue, 27 Mar 2012 22:42:19 +0000 Subject: [PATCH] rework iterator/iteratoraggregate parts of oop5.iteration (no more "you"!) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@324593 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/iterations.xml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/language/oop5/iterations.xml b/language/oop5/iterations.xml index 7bc42729c1..46906aec94 100644 --- a/language/oop5/iterations.xml +++ b/language/oop5/iterations.xml @@ -65,13 +65,15 @@ private => private var - As the output shows, the &foreach; iterated through all - visible variables that can be - accessed. To take it a step further you can implement one - of PHP 5's internal interface named - Iterator. 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 + visible properties that could be + accessed. + + + To take it a step further, the Iterator + interface may be implemented. + This allows the object to dictate how it will be iterated and what values will + be available on each iteration. @@ -162,9 +164,14 @@ valid: - You can also define your class so that it doesn't have to define - all the Iterator functions by simply implementing - the PHP 5 IteratorAggregate interface. + The IteratorAggregate + interface + can be used as an alternative to implementing all of the + Iterator methods. + IteratorAggregate only requires the + implementation of a single method, + IteratorAggregate::getIterator, which should return + an instance of a class implementing Iterator.