Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/var-dumper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.4.0
Choose a base ref
...
head repository: symfony/var-dumper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.4.1
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 1, 2021

  1. Copy the full SHA
    f2c45f0 View commit details
  2. Merge branch '4.4' into 5.3

    * 4.4:
      [gha] swap the php versions we use in jobs
      [DoctrineBridge] fix calling get_class on non-object
      Update PR template
      [HttpClient] Fix handling error info in MockResponse
    nicolas-grekas committed Dec 1, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    d139af7 View commit details
  3. Merge branch '5.3' into 5.4

    * 5.3:
      [gha] swap the php versions we use in jobs
      [DoctrineBridge] fix calling get_class on non-object
      Update PR template
      [HttpClient] Fix handling error info in MockResponse
    nicolas-grekas committed Dec 1, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    targos Michaël Zasso
    Copy the full SHA
    2366ac8 View commit details
Showing with 26 additions and 92 deletions.
  1. +11 −9 Caster/ReflectionCaster.php
  2. +15 −83 Tests/Caster/ReflectionCasterTest.php
20 changes: 11 additions & 9 deletions Caster/ReflectionCaster.php
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
array_unshift($trace, [
'function' => 'yield',
'file' => $function->getExecutingFile(),
'line' => $function->getExecutingLine() - 1,
'line' => $function->getExecutingLine() - (int) (\PHP_VERSION_ID < 80100),
]);
$trace[] = $frame;
$a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);
@@ -289,15 +289,17 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
unset($a[$prefix.'allowsNull']);
}

try {
$a[$prefix.'default'] = $v = $c->getDefaultValue();
if ($c->isDefaultValueConstant()) {
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
}
if (null === $v) {
unset($a[$prefix.'allowsNull']);
if ($c->isOptional()) {
try {
$a[$prefix.'default'] = $v = $c->getDefaultValue();
if ($c->isDefaultValueConstant()) {
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
}
if (null === $v) {
unset($a[$prefix.'allowsNull']);
}
} catch (\ReflectionException $e) {
}
} catch (\ReflectionException $e) {
}

return $a;
98 changes: 15 additions & 83 deletions Tests/Caster/ReflectionCasterTest.php
Original file line number Diff line number Diff line change
@@ -138,21 +138,8 @@ public function testReflectionParameter()
{
$var = new \ReflectionParameter(reflectionParameterFixture::class, 0);

if (\PHP_VERSION_ID < 80100) {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "arg1"
position: 0
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
default: null
}
EOTXT
, $var
);
} else {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "arg1"
position: 0
@@ -161,8 +148,7 @@ public function testReflectionParameter()
}
EOTXT
, $var
);
}
);
}

public function testReflectionParameterScalar()
@@ -484,108 +470,54 @@ public function testGenerator()
$generator = new GeneratorDemo();
$generator = $generator->baz();

if (\PHP_VERSION_ID < 80100) {
$expectedDump = <<<'EODUMP'
$expectedDump = <<<'EODUMP'
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
executing: {
%s: {
%sGeneratorDemo.php:14 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
› {
› yield from bar();
› }
}
}
%A}
closed: false
}
EODUMP;
} else {
$expectedDump = <<<'EODUMP'
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
trace: {
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:13 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
› public function baz()
› {
› yield from bar();
}
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
}
closed: false
}
EODUMP;
}

$this->assertDumpMatchesFormat($expectedDump, $generator);

foreach ($generator as $v) {
break;
}

if (\PHP_VERSION_ID < 80100) {
$expectedDump = <<<'EODUMP'
$expectedDump = <<<'EODUMP'
array:2 [
0 => ReflectionGenerator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
%s: {
%s%eTests%eFixtures%eGeneratorDemo.php:%d {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
› {
› yield 1;
› }
}
%A › yield 1;
%A }
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
}
%A }
closed: false
}
1 => Generator {
executing: {
%sGeneratorDemo.php:10 {
%s: {
%s%eTests%eFixtures%eGeneratorDemo.php:%d {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
› yield 1;
› }
}
}
closed: false
}
]
EODUMP;
} else {
$expectedDump = <<<'EODUMP'
array:2 [
0 => ReflectionGenerator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
› {
› yield 1;
› }
}
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
}
closed: false
}
1 => Generator {
trace: {
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
› {
› yield 1;
› }
}
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {}
}
%A }
closed: false
}
]
EODUMP;
}

$r = new \ReflectionGenerator($generator);
$this->assertDumpMatchesFormat($expectedDump, [$r, $r->getExecutingGenerator()]);