Bug #67631 [Csd->Nab]: Yield command doens't work

From: Date: Wed, 16 Jul 2014 14:13:45 +0000
Subject: Bug #67631 [Csd->Nab]: Yield command doens't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186667@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67631&edit=1

 ID:                 67631
 Updated by:         rasmus@php.net
 Reported by:        lferro9000 at gmail dot com
 Summary:            Yield command doens't work
-Status:             Closed
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   MacOSx
 PHP Version:        5.5.14
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2014-07-16 12:56:51] lferro9000 at gmail dot com

Issue with multiple versions of PHP on the computer.

------------------------------------------------------------------------
[2014-07-16 12:38:52] lferro9000 at gmail dot com

Line 5 i mean (the line with the yield statement).

------------------------------------------------------------------------
[2014-07-16 12:37:43] lferro9000 at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=67631&edit=1


Thread (4 messages)

« previous php.bugs (#186667) next »