Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c1343f

Browse filesBrowse files
committed
bug #41701 [VarDumper] Fix tests for PHP 8.1 (alexandre-daubois)
This PR was merged into the 4.4 branch. Discussion ---------- [VarDumper] Fix tests for PHP 8.1 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Part of #41552 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | N/A Commits ------- f2b0822 [VarDumper] Fix tests for PHP 8.1
2 parents 6f9f4be + f2b0822 commit 0c1343f
Copy full SHA for 0c1343f

File tree

1 file changed

+72
-6
lines changed
Filter options

1 file changed

+72
-6
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
+72-6Lines changed: 72 additions & 6 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 { …}
@@ -456,6 +489,39 @@ public function testGenerator()
456489
}
457490
]
458491
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+
› {
501+
› yield 1;
502+
› }
503+
}
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() {}
519+
}
520+
closed: false
521+
}
522+
]
523+
EODUMP;
524+
}
459525

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.