Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 5.4:
  Avoid duplicated session listener registration in tests
  [HttpFoundation] fix SessionHandlerFactory using connections
  [gha] swap the php versions we use in jobs
  [DoctrineBridge] fix calling get_class on non-object
  Update PR template
  ResponseListener needs only 2 parameters
  [Lock] create lock table if it does not exist
  [HttpClient] Fix handling error info in MockResponse
  [SecurityBundle] Fix invalid reference with `always_authenticate_before_granting`
  Bump Symfony version to 5.4.1
  Update VERSION for 5.4.0
  Update CHANGELOG for 5.4.0
  • Loading branch information
nicolas-grekas committed Dec 1, 2021
2 parents 18d9a17 + 2366ac8 commit f4a219b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 92 deletions.
20 changes: 11 additions & 9 deletions Caster/ReflectionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
98 changes: 15 additions & 83 deletions Tests/Caster/ReflectionCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -161,8 +148,7 @@ public function testReflectionParameter()
}
EOTXT
, $var
);
}
);
}

public function testReflectionParameterScalar()
Expand Down Expand Up @@ -436,108 +422,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()]);
Expand Down

0 comments on commit f4a219b

Please sign in to comment.