Skip to content

Commit

Permalink
[VarDumper] fix tests & displaying generators
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 6, 2019
1 parent 71bf18e commit d36dd76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
8 changes: 1 addition & 7 deletions Caster/ReflectionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ public static function unsetClosureFileInfo(\Closure $c, array $a)

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);
Expand Down Expand Up @@ -136,9 +132,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
} 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;
Expand Down
23 changes: 11 additions & 12 deletions Tests/Caster/ReflectionCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,11 @@ public function testGenerator()
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
Expand All @@ -208,6 +207,7 @@ public function testGenerator()
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
› {
› yield 1;
› }
Expand All @@ -219,12 +219,11 @@ public function testGenerator()
}
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
Expand Down

0 comments on commit d36dd76

Please sign in to comment.