Doc #64102 [NEW]: Manual incorrectly says empty "return" in generator has no effect

From: Date: Wed, 30 Jan 2013 00:06:37 +0000
Subject: Doc #64102 [NEW]: Manual incorrectly says empty "return" in generator has no effect
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9498@lists.php.net to get a copy of this message
From: jmcgrew at elance dot com Operating system: Windows PHP version: 5.5.0alpha4 Package: Documentation problem Bug Type: Documentation Problem Bug description:Manual incorrectly says empty "return" in generator has no effect 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 bug report at https://bugs.php.net/bug.php?id=64102&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64102&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64102&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64102&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64102&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64102&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64102&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64102&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64102&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64102&r=support Expected behavior: https://bugs.php.net/fix.php?id=64102&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64102&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64102&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64102&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64102&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64102&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64102&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64102&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64102&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64102&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64102&r=mysqlcfg

« previous php.doc.bugs (#9498) next »