From 482bc1d69cafe16e5525f750c2aa84b22fc45278 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Sat, 30 Jun 2018 11:56:50 +0000 Subject: [PATCH] Clarify behavior of generator (functions) Patch provided by an anonymous user. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345249 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/generators.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/language/generators.xml b/language/generators.xml index 9fc3a09f4c..4c1f03ed45 100644 --- a/language/generators.xml +++ b/language/generators.xml @@ -98,7 +98,7 @@ Single digit odd numbers from xrange(): 1 3 5 7 9 <classname>Generator</classname> objects - When a generator function is called for the first time, an object of the + When a generator function is called, a new object of the internal Generator class is returned. This object implements the Iterator interface in much the same way as a forward-only iterator object would, and provides methods that can @@ -119,13 +119,13 @@ Single digit odd numbers from xrange(): 1 3 5 7 9 When a generator function is called, it returns an object that can be iterated over. When you iterate over that object (for instance, via a - &foreach; loop), PHP will call the generator function each time it needs a + &foreach; loop), PHP will call the object's iteration methods each time it needs a value, then saves the state of the generator when the generator yields a value so that it can be resumed when the next value is required. - Once there are no more values to be yielded, then the generator function + Once there are no more values to be yielded, then the generator can simply exit, and the calling code continues just as if an array has run out of values.