[VarDumper] fix tests & displaying generators

This commit is contained in:
Nicolas Grekas 2019-11-06 10:34:32 +01:00
parent ba1ba971d6
commit bcf43a4593
2 changed files with 12 additions and 19 deletions

View File

@ -80,10 +80,6 @@ class ReflectionCaster
public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested)
{
if (!class_exists('ReflectionGenerator', false)) {
return $a;
}
// Cannot create ReflectionGenerator based on a terminated Generator
try {
$reflectionGenerator = new \ReflectionGenerator($c);
@ -136,9 +132,7 @@ class ReflectionCaster
} else {
$function = new FrameStub($frame, false, true);
$function = ExceptionCaster::castFrameStub($function, [], $function, true);
$a[$prefix.'executing'] = new EnumStub([
"\0~separator= \0".$frame['class'].$frame['type'].$frame['function'].'()' => $function[$prefix.'src'],
]);
$a[$prefix.'executing'] = $function[$prefix.'src'];
}
$a[Caster::PREFIX_VIRTUAL.'closed'] = false;

View File

@ -184,12 +184,11 @@ EOTXT
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {
%sGeneratorDemo.php:14 {
{
yield from bar();
}
}
%sGeneratorDemo.php:14 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
{
yield from bar();
}
}
}
closed: false
@ -208,6 +207,7 @@ array:2 [
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
{
yield 1;
}
@ -219,12 +219,11 @@ array:2 [
}
1 => Generator {
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {
%sGeneratorDemo.php:10 {
yield 1;
}
}
%sGeneratorDemo.php:10 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
yield 1;
}
}
}
closed: false