Skip to content

Commit f4a219b

Browse files
Merge branch '5.4' into 6.0
* 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
2 parents 18d9a17 + 2366ac8 commit f4a219b

File tree

2 files changed

+26
-92
lines changed

2 files changed

+26
-92
lines changed

Caster/ReflectionCaster.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
144144
array_unshift($trace, [
145145
'function' => 'yield',
146146
'file' => $function->getExecutingFile(),
147-
'line' => $function->getExecutingLine() - 1,
147+
'line' => $function->getExecutingLine() - (int) (\PHP_VERSION_ID < 80100),
148148
]);
149149
$trace[] = $frame;
150150
$a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);
@@ -289,15 +289,17 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
289289
unset($a[$prefix.'allowsNull']);
290290
}
291291

292-
try {
293-
$a[$prefix.'default'] = $v = $c->getDefaultValue();
294-
if ($c->isDefaultValueConstant()) {
295-
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
296-
}
297-
if (null === $v) {
298-
unset($a[$prefix.'allowsNull']);
292+
if ($c->isOptional()) {
293+
try {
294+
$a[$prefix.'default'] = $v = $c->getDefaultValue();
295+
if ($c->isDefaultValueConstant()) {
296+
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
297+
}
298+
if (null === $v) {
299+
unset($a[$prefix.'allowsNull']);
300+
}
301+
} catch (\ReflectionException $e) {
299302
}
300-
} catch (\ReflectionException $e) {
301303
}
302304

303305
return $a;

Tests/Caster/ReflectionCasterTest.php

Lines changed: 15 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,8 @@ public function testReflectionParameter()
138138
{
139139
$var = new \ReflectionParameter(reflectionParameterFixture::class, 0);
140140

141-
if (\PHP_VERSION_ID < 80100) {
142-
$this->assertDumpMatchesFormat(
143-
<<<'EOTXT'
144-
ReflectionParameter {
145-
+name: "arg1"
146-
position: 0
147-
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
148-
default: null
149-
}
150-
EOTXT
151-
, $var
152-
);
153-
} else {
154-
$this->assertDumpMatchesFormat(
155-
<<<'EOTXT'
141+
$this->assertDumpMatchesFormat(
142+
<<<'EOTXT'
156143
ReflectionParameter {
157144
+name: "arg1"
158145
position: 0
@@ -161,8 +148,7 @@ public function testReflectionParameter()
161148
}
162149
EOTXT
163150
, $var
164-
);
165-
}
151+
);
166152
}
167153

168154
public function testReflectionParameterScalar()
@@ -436,108 +422,54 @@ public function testGenerator()
436422
$generator = new GeneratorDemo();
437423
$generator = $generator->baz();
438424

439-
if (\PHP_VERSION_ID < 80100) {
440-
$expectedDump = <<<'EODUMP'
425+
$expectedDump = <<<'EODUMP'
441426
Generator {
442427
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
443-
executing: {
428+
%s: {
444429
%sGeneratorDemo.php:14 {
445430
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
446431
› {
447432
› yield from bar();
448433
› }
449434
}
450-
}
435+
%A}
451436
closed: false
452437
}
453438
EODUMP;
454-
} else {
455-
$expectedDump = <<<'EODUMP'
456-
Generator {
457-
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
458-
trace: {
459-
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:13 {
460-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
461-
› public function baz()
462-
› {
463-
› yield from bar();
464-
}
465-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
466-
}
467-
closed: false
468-
}
469-
EODUMP;
470-
}
471439

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

474442
foreach ($generator as $v) {
475443
break;
476444
}
477445

478-
if (\PHP_VERSION_ID < 80100) {
479-
$expectedDump = <<<'EODUMP'
446+
$expectedDump = <<<'EODUMP'
480447
array:2 [
481448
0 => ReflectionGenerator {
482449
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
483-
trace: {
484-
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
450+
%s: {
451+
%s%eTests%eFixtures%eGeneratorDemo.php:%d {
485452
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
486-
› {
487-
› yield 1;
488-
› }
489-
}
453+
%A › yield 1;
454+
%A }
490455
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
491456
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
492-
}
457+
%A }
493458
closed: false
494459
}
495460
1 => Generator {
496-
executing: {
497-
%sGeneratorDemo.php:10 {
461+
%s: {
462+
%s%eTests%eFixtures%eGeneratorDemo.php:%d {
498463
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
499464
› yield 1;
500465
› }
501466
502467
}
503-
}
504-
closed: false
505-
}
506-
]
507-
EODUMP;
508-
} else {
509-
$expectedDump = <<<'EODUMP'
510-
array:2 [
511-
0 => ReflectionGenerator {
512-
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
513-
trace: {
514-
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
515-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
516-
› {
517-
› yield 1;
518-
› }
519-
}
520-
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
521-
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
522-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
523-
}
524-
closed: false
525-
}
526-
1 => Generator {
527-
trace: {
528-
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:9 {
529-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
530-
› {
531-
› yield 1;
532-
› }
533-
}
534-
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {}
535-
}
468+
%A }
536469
closed: false
537470
}
538471
]
539472
EODUMP;
540-
}
541473

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

0 commit comments

Comments
 (0)