From 0255049bbb961a8dbfbe81c58fbb3c80781b7842 Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Wed, 20 May 2015 18:19:23 -0400 Subject: [PATCH] Don't use php7 ReflectionGenerator in PHP5.x branch --- lib/functions.php | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index 0889fc2..4918e79 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -538,9 +538,10 @@ function __coroutineAdvance($cs) { } else { $promisor = $cs->promisor; $cs->promisor = null; - $promisor->fail(new \DomainException( - __generateYieldError($cs->generator, $key, $yielded) - )); + $promisor->fail(new \DomainException(sprintf( + "Unexpected Generator yield (Promise|null expected); %s yielded at key %s", + is_object($yielded) ? get_class($yielded) : gettype($yielded) + ))); return; } @@ -579,20 +580,4 @@ function __coroutineSend($error, $result, $cs) { $promisor->fail($uncaught); } } -} - -function __generateYieldError(\Generator $generator, $key, $yielded) { - $reflectionGen = new \ReflectionGenerator($generator); - $executingGen = $reflectionGen->getExecutingGenerator(); - if ($isSubgenerator = ($executingGen !== $generator)) { - $reflectionGen = new \ReflectionGenerator($executingGen); - } - - return sprintf( - "Unexpected Generator yield (Promise|null expected); %s yielded at key %s on line %s in %s", - (is_object($yielded) ? get_class($yielded) : gettype($yielded)), - $key, - $reflectionGen->getExecutingLine(), - $reflectionGen->getExecutingFile() - ); -} +} \ No newline at end of file