/hphp/test/zend/good/Zend/tests/bug62991.php
PHP | 33 lines | 27 code | 6 blank | 0 comment | 0 complexity | 752f15d675b96cce7c27d3be91c5fab3 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- function test( varray $array )
- {
- $closure = function() use ( $array ) {
- print_r( $array );
- yield "hi";
- };
- return $closure();
- }
- function test2( varray $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.
- }
- <<__EntryPoint>> function main(): void {
- $generator = test(varray[ 1, 2, 3 ] );
- foreach($generator as $something) {
- }
- $generator = test2(varray[ 1, 2, 3 ] );
- foreach($generator() as $something) {
- }
- $generator = test2(varray[ 1, 2, 3 ] );
- echo "okey\n";
- }