Edit report at https://bugs.php.net/bug.php?id=65092&edit=1

 ID:                 65092
 Updated by:         ni...@php.net
 Reported by:        michael at squiloople dot com
 Summary:            Neither errors nor result with generators and
                     anonymous functions
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Arrays related
 Operating System:   Windows Vista SP2
 PHP Version:        5.5.0
 Block user comment: N
 Private report:     N

 New Comment:

You are trying to iterate over a closure, so you get an empty loop (closures 
have no properties).

If you want to iterate over the generator you need to call the closure first.


Previous Comments:
------------------------------------------------------------------------
[2013-06-21 21:58:40] michael at squiloople dot com

Description:
------------
When using generators with an anonymous function neither an error nor the 
expected 
result are shown.

Test script:
---------------
  foreach (function ()
  {

    for ($i = 1; $i <= 10; ++$i)
    {
      yield $i => $i;
    }

  } as $key => $value)
  {
    echo $key . ': ' . $value . '<br>';
  }

Expected result:
----------------
Either:

1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
7: 7
8: 8
9: 9
10: 10

Or an error of some sort.

Actual result:
--------------
[neither result nor error]


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65092&edit=1

Reply via email to