8000 [VarDumper] Fix tests for PHP 8.1 · symfony/symfony@44efb72 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44efb72

Browse files
[VarDumper] Fix tests for PHP 8.1
1 parent 0fa07c6 commit 44efb72

File tree

1 file changed

+73
-7
lines changed

1 file changed

+73
-7
lines changed

src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,31 @@ public function testReflectionParameter()
122122
{
123123
$var = new \ReflectionParameter(reflectionParameterFixture::class, 0);
124124

125-
$this->assertDumpMatchesFormat(
126-
<<<'EOTXT'
125+
if (\PHP_VERSION_ID < 80100) {
126+
$this->assertDumpMatchesFormat(
127+
<<<'EOTXT'
127128
ReflectionParameter {
128129
+name: "arg1"
129130
position: 0
130131
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
131132
default: null
132133
}
133134
EOTXT
134-
, $var
135-
);
135+
, $var
136+
);
137+
} else {
138+
$this->assertDumpMatchesFormat(
139+
<<<'EOTXT'
140+
ReflectionParameter {
141+
+name: "arg1"
142+
position: 0
143+
allowsNull: true
144+
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
145+
}
146+
EOTXT
147+
, $var
148+
);
149+
}
136150
}
137151

138152
public function testReflectionParameterScalar()
@@ -406,7 +420,8 @@ public function testGenerator()
406420
$generator = new GeneratorDemo();
407421
$generator = $generator->baz();
408422

409-
$expectedDump = <<<'EODUMP'
423+
if (\PHP_VERSION_ID < 80100) {
424+
$expectedDump = <<<'EODUMP'
410425
Generator {
411426
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
412427
executing: {
@@ -420,14 +435,32 @@ public function testGenerator()
420435
closed: false
421436
}
422437
EODUMP;
438+
} else {
439+
$expectedDump = <<<'EODUMP'
440+
Generator {
441+
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
442+
trace: {
443+
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:13 {
444+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
445+
› public function baz()
446+
› {
447+
› yield from bar();
448+
}
449+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
450+
}
451+
closed: false
452+
}
453+
EODUMP;
454+
}
423455

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

426458
foreach ($generator as $v) {
427459
break;
428460
}
429461

430-
$expectedDump = <<<'EODUMP'
462+
if (\PHP_VERSION_ID < 80100) {
463+
$expectedDump = <<<'EODUMP'
431464
array:2 [
432465
0 => ReflectionGenerator {
433466
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
@@ -447,15 +480,48 @@ public function testGenerator()
447480
executing: {
448481
%sGeneratorDemo.php:10 {
449482
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
483+
› {
484+
› yield 1;
485+
› }
486+
}
487+
}
488+
closed: false
489+
}
490+
]
491+
EODUMP;
492+
} else {
493+
$expectedDump = <<<'EODUMP'
494+
array:2 [
495+
0 => ReflectionGenerator {
496+
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
497+
trace: {
498+
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
499+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
500+
› {
450501
› yield 1;
451502
› }
452-
453503
}
504+
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
505+
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
506+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
507+
}
508+
closed: false
509+
}
510+
1 => Generator {
511+
trace: {
512+
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:9 {
513+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
514+
› {
515+
› yield 1;
516+
› }
517+
}
518+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {}
454519
}
455520
closed: false
456521
}
457522
]
458523
EODUMP;
524+
}
459525

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

0 commit comments

Comments
 (0)
0