php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64102 Manual incorrectly says empty "return" in generator has no effect
Submitted: 2013-01-30 00:06 UTC Modified: 2013-02-24 09:32 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jmcgrew at elance dot com Assigned: vrana (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.5.0alpha4 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jmcgrew at elance dot com
New email:
PHP Version: OS:

 

 [2013-01-30 00:06 UTC] 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"; }



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-24 09:29 UTC] 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-02-24 09:32 UTC] vrana@php.net
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.


 [2013-02-24 09:32 UTC] vrana@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vrana
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 08:00:01 2026 UTC