1
0
mirror of https://github.com/danog/amp.git synced 2025-01-21 21:01:16 +01:00

Return promise/result from bound functions

This commit is contained in:
Daniel Lowrey 2014-12-02 12:43:00 -05:00
parent ec7b77d156
commit 934d1aeffb
2 changed files with 5 additions and 4 deletions

View File

@ -200,9 +200,9 @@ trait GeneratorResolver {
if (is_callable($current)) {
$promise = new Success(function() use ($current) {
$result = call_user_func_array($current, func_get_args());
if ($result instanceof \Generator) {
$this->resolveGenerator($result);
}
return $result instanceof \Generator
? $this->resolveGenerator($result)
: $result;
});
} else {
$promise = new Failure(new \DomainException(

View File

@ -298,7 +298,8 @@ class GeneratorResolverTest extends \PHPUnit_Framework_TestCase {
// Because this Generator function is bound to the reactor it should be
// automatically resolved and our repeating watcher should be cancelled
// allowing the reactor to stop running.
$boundFunc();
$result = $boundFunc();
$this->assertInstanceOf('Amp\\Promise', $result);
});
}
}