diff --git a/Tests/Caster/ReflectionCasterTest.php b/Tests/Caster/ReflectionCasterTest.php index 96511116..d0285127 100644 --- a/Tests/Caster/ReflectionCasterTest.php +++ b/Tests/Caster/ReflectionCasterTest.php @@ -21,6 +21,7 @@ use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionIntersectionTypeFixture; use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionNamedTypeFixture; use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionUnionTypeFixture; +use Symfony\Component\VarDumper\Tests\Fixtures\ReflectionUnionTypeWithIntersectionFixture; /** * @author Nicolas Grekas @@ -94,7 +95,7 @@ public function testClosureCaster() $b: & 123 } file: "%sReflectionCasterTest.php" - line: "87 to 87" + line: "88 to 88" } EOTXT , $var @@ -318,6 +319,44 @@ public function testReflectionIntersectionType() ); } + /** + * @requires PHP 8.2 + */ + public function testReflectionUnionTypeWithIntersection() + { + $var = (new \ReflectionProperty(ReflectionUnionTypeWithIntersectionFixture::class, 'a'))->getType(); + $this->assertDumpMatchesFormat( + <<<'EOTXT' +ReflectionUnionType { + allowsNull: true + types: array:2 [ + 0 => ReflectionIntersectionType { + allowsNull: false + types: array:2 [ + 0 => ReflectionNamedType { + name: "Traversable" + allowsNull: false + isBuiltin: false + } + 1 => ReflectionNamedType { + name: "Countable" + allowsNull: false + isBuiltin: false + } + ] + } + 1 => ReflectionNamedType { + name: "null" + allowsNull: true + isBuiltin: true + } + ] +} +EOTXT + , $var + ); + } + public function testExtendsReflectionType() { $var = new ExtendsReflectionTypeFixture(); diff --git a/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php b/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php new file mode 100644 index 00000000..630d0e77 --- /dev/null +++ b/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php @@ -0,0 +1,8 @@ +