8000 [VarDumper] Fix test suite with PHP 8.4 · symfony/symfony@94426aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 94426aa

Browse files
[VarDumper] Fix test suite with PHP 8.4
1 parent c6506c4 commit 94426aa

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@ public static function castType(\ReflectionType $c, array $a, Stub $stub, bool $
116116

117117
public static function castAttribute(\ReflectionAttribute $c, array $a, Stub $stub, bool $isNested)
118118
{
119-
self::addMap($a, $c, [
119+
$map = [
120120
'name' => 'getName',
121121
'arguments' => 'getArguments',
122-
]);
122+
];
123+
124+
if (\PHP_VERSION_ID >= 80400) {
125+
unset($map['name']);
126+
}
127+
128+
self::addMap($a, $c, $map);
123129

124130
return $a;
125131
}

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,14 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
599599
public function testReflectionClassWithAttribute()
600600
{
601601
$var = new \ReflectionClass(LotsOfAttributes::class);
602+
$dumpedAttributeNameProperty = (\PHP_VERSION_ID < 80400 ? '' : '+').'name';
602603

603-
$this->assertDumpMatchesFormat(<<< 'EOTXT'
604+
$this->assertDumpMatchesFormat(<<<EOTXT
604605
ReflectionClass {
605606
+name: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
606607
%A attributes: array:1 [
607608
0 => ReflectionAttribute {
608-
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
609+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
609610
arguments: []
610611
}
611612
]
@@ -621,14 +622,15 @@ public function testReflectionClassWithAttribute()
621622
public function testReflectionMethodWithAttribute()
622623
{
623624
$var = new \ReflectionMethod(LotsOfAttributes::class, 'someMethod');
625+
$dumpedAttributeNameProperty = (\PHP_VERSION_ID < 80400 ? '' : '+').'name';
624626

625-
$this->assertDumpMatchesFormat(<<< 'EOTXT'
627+
$this->assertDumpMatchesFormat(<<<EOTXT
626628
ReflectionMethod {
627629
+name: "someMethod"
628630
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
629631
%A attributes: array:1 [
630632
0 => ReflectionAttribute {
631-
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
633+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
632634
arguments: array:1 [
633635
0 => "two"
634636
]
@@ -646,14 +648,15 @@ public function testReflectionMethodWithAttribute()
646648
public function testReflectionPropertyWithAttribute()
647649
{
648650
$var = new \ReflectionProperty(LotsOfAttributes::class, 'someProperty');
651+
$dumpedAttributeNameProperty = (\PHP_VERSION_ID < 80400 ? '' : '+').'name';
649652

650-
$this->assertDumpMatchesFormat(<<< 'EOTXT'
653+
$this->assertDumpMatchesFormat(<<<EOTXT
651654
ReflectionProperty {
652655
+name: "someProperty"
653656
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
654657
%A attributes: array:1 [
655658
0 => ReflectionAttribute {
656-
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
659+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
657660
arguments: array:2 [
658661
0 => "one"
659662
"extra" => "hello"
@@ -671,22 +674,23 @@ public function testReflectionPropertyWithAttribute()
671674
public function testReflectionClassConstantWithAttribute()
672675
{
673676
$var = new \ReflectionClassConstant(LotsOfAttributes::class, 'SOME_CONSTANT');
677+
$dumpedAttributeNameProperty = (\PHP_VERSION_ID < 80400 ? '' : '+').'name';
674678

675-
$this->assertDumpMatchesFormat(<<< 'EOTXT'
679+
$this->assertDumpMatchesFormat(<<<EOTXT
676680
ReflectionClassConstant {
677681
+name: "SOME_CONSTANT"
678682
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
679683
modifiers: "public"
680684
value: "some value"
681685
attributes: array:2 [
682686
0 => ReflectionAttribute {
683-
name: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
687+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
684688
arguments: array:1 [
685689
0 => "one"
686690
]
687691
}
688692
1 => ReflectionAttribute {
689-
name: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
693+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
690694
arguments: array:1 [
691695
0 => "two"
692696
]
@@ -703,14 +707,15 @@ public function testReflectionClassConstantWithAttribute()
703707
public function testReflectionParameterWithAttribute()
704708
{
705709
$var = new \ReflectionParameter([LotsOfAttributes::class, 'someMethod'], 'someParameter');
710+
$dumpedAttributeNameProperty = (\PHP_VERSION_ID < 80400 ? '' : '+').'name';
706711

707-
$this->assertDumpMatchesFormat(<<< 'EOTXT'
712+
$this->assertDumpMatchesFormat(<<<EOTXT
708713
ReflectionParameter {
709714
+name: "someParameter"
710715
position: 0
711716
attributes: array:1 [
712717
0 => ReflectionAttribute {
713-
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
718+
$dumpedAttributeNameProperty: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
714719
arguments: array:1 [
715720
0 => "three"
716721
]

0 commit comments

Comments
 (0)
0