function test()
{
    $x = new X();
    $f = $x->gen(function ($x) {
        var_dump(get_class($x));
    });
    foreach ($f() as $e) {
        var_dump($e);
    }
}
示例#2
0
文件: 2072.php 项目: badlamer/hhvm
<?php

trait T
{
    public static function gen()
    {
        static $x;
        (yield ++$x);
        (yield 2);
        (yield ++$x);
    }
}
class X
{
    use T;
}
class Y extends X
{
}
$g = X::gen();
foreach ($g as $i) {
    var_dump($i);
}