Doc #64102 [Opn->Csd]: Manual incorrectly says empty "return" in generator has no effect
| From: | vrana@php.net | Date: | Sun, 24 Feb 2013 09:32:52 +0000 |
| Subject: | Doc #64102 [Opn->Csd]: Manual incorrectly says empty "return" in generator has no effect | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9580@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64102&edit=1
ID: 64102
Updated by: vrana@php.net
Reported by: jmcgrew at elance dot com
Summary: Manual incorrectly says empty "return" in generator
has no effect
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows
PHP Version: 5.5.0alpha4
-Assigned To:
+Assigned To: vrana
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2013-02-24 09:29:25] vrana@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=329570
Log: Explain return inside generator (fixes bug #64102)
------------------------------------------------------------------------
[2013-01-30 00:06:37] jmcgrew at elance dot com
Description:
------------
---
From manual page: http://www.php.net/language.generators.syntax
---
The note box at the top says, "An empty return statement is valid syntax within a
generator, but meaningless and will do nothing."
But in fact, an empty return statement is meaningful and does something. It exits
the generator function and stops yielding.
Test script:
---------------
// this yields 5 and 6 but not 7
function foo() {
yield 5;
yield 6;
return;
yield 7;
}
foreach (foo() as $x) { echo "$x\n"; }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64102&edit=1