Bug #67631 [NEW]: Yield command doens't work
| From: | lferro9000 at gmail dot com | Date: | Wed, 16 Jul 2014 12:37:44 +0000 |
| Subject: | Bug #67631 [NEW]: Yield command doens't work | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186662@lists.php.net to get a copy of this message | ||
From: lferro9000 at gmail dot com
Operating system: MacOSx
PHP version: 5.5.14
Package: *General Issues
Bug Type: Bug
Bug description:Yield command doens't work
Description:
------------
---
From manual page: http://www.php.net/language.generators.syntax
---
The Yield command which has the syntax:
yield $var;
In it's basic form doesn't work and issues on CLI the following error:
Parse error: parse error in test.php on line 7
Test script:
---------------
Test script is the example posted on the generators page:
<?php
function gen_one_to_three() {
for ($i = 1; $i <= 3; $i++) {
// Note that $i is preserved between yields.
yield $i;
}
}
$generator = gen_one_to_three();
foreach ($generator as $value) {
echo "$value\n";
}
Expected result:
----------------
The yield command should work as documented.
--
Edit bug report at https://bugs.php.net/bug.php?id=67631&edit=1
--