mirror of
https://github.com/php/php-src.git
synced 2024-12-25 09:49:08 +08:00
f3e5bbe6f3
Per RFC: https://wiki.php.net/rfc/arrow_functions_v2 Co-authored-by: Levi Morrison <levim@php.net> Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
29 lines
407 B
PHP
29 lines
407 B
PHP
--TEST--
|
|
Yield inside arrow functions
|
|
--FILE--
|
|
<?php
|
|
|
|
// This doesn't make terribly much sense, but it works...
|
|
|
|
$fn = fn() => yield 123;
|
|
foreach ($fn() as $val) {
|
|
var_dump($val);
|
|
}
|
|
|
|
$fn = fn() => yield from [456, 789];
|
|
foreach ($fn() as $val) {
|
|
var_dump($val);
|
|
}
|
|
|
|
$fn = fn() => fn() => yield 987;
|
|
foreach ($fn()() as $val) {
|
|
var_dump($val);
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(123)
|
|
int(456)
|
|
int(789)
|
|
int(987)
|