hiphop-php /hphp/test/zend/good/Zend/tests/bug62991.php

Language PHP Lines 34
MD5 Hash 84b60f6f513327a17f643ba79c852d3b Estimated Cost $538 (why?)
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

function test( array $array )
{
    $closure = function() use ( $array ) {
        print_r( $array );
        yield "hi";
    };
    return $closure();
}

function test2( array $array )
{
    $closure = function() use ( $array ) {
        print_r( $array );
        yield "hi";
    };
    return $closure; // if you return the $closure and call it outside this function it works.
}

$generator = test(array( 1, 2, 3 ) );
foreach($generator as $something) {
}

$generator = test2(array( 1, 2, 3 ) );
foreach($generator() as $something) {
}


$generator = test2(array( 1, 2, 3 ) );

echo "okey\n";
?>
Back to Top