1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00

Fix missing parameter if coroutine invoked without args

This commit is contained in:
Daniel Lowrey 2015-05-27 18:33:20 -04:00
parent 6c440b2797
commit 0c4f04c6ab

View File

@ -471,8 +471,8 @@ function wait(Promise $promise, Reactor $reactor = null) {
* @return callable Returns the wrapped callable
*/
function coroutine(callable $func, Reactor $reactor = null, callable $promisifier = null) {
return function($data) use ($func, $reactor, $promisifier) {
$result = $func($data);
return function() use ($func, $reactor, $promisifier) {
$result = \call_user_func_array($func, func_get_args());
return ($result instanceof \Generator)
? resolve($result, $reactor, $promisifier)
: $result;