mirror of
https://github.com/danog/amp.git
synced 2025-01-22 05:11:42 +01:00
Support extended generator error debugging output in PHP7
This commit is contained in:
parent
deedb4a7fa
commit
57c0f222ea
@ -641,9 +641,23 @@ function __coroutineSend($error, $result, $cs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __coroutineYieldError(\Generator $generator, $key, $yielded) {
|
function __coroutineYieldError(\Generator $generator, $key, $yielded) {
|
||||||
|
$type = is_object($yielded) ? get_class($yielded) : gettype($yielded);
|
||||||
|
$msg = "Unexpected Generator yield (Promise|\"return\"|null expected); {$type} yielded at key {$key}";
|
||||||
|
if (PHP_MAJOR_VERSION < 7) {
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reflGen = new \ReflectionGenerator($generator);
|
||||||
|
$exeGen = $reflGen->getExecutingGenerator();
|
||||||
|
if ($exeGen !== $generator) {
|
||||||
|
// We're executing a subgenerator; use the correct reflection
|
||||||
|
$reflGen = new \ReflectionGenerator($exeGen);
|
||||||
|
}
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'Unexpected Generator yield (Promise|"return"|null expected); %s yielded at key %s',
|
"%s on line %s in %s",
|
||||||
(is_object($yielded) ? get_class($yielded) : gettype($yielded)),
|
$msg,
|
||||||
$key
|
$reflGen->getExecutingLine(),
|
||||||
|
$reflGen->getExecutingFile()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user