diff --git a/src/Tempest/Reflection/src/TypeReflector.php b/src/Tempest/Reflection/src/TypeReflector.php index 6c971036a..80708d84e 100644 --- a/src/Tempest/Reflection/src/TypeReflector.php +++ b/src/Tempest/Reflection/src/TypeReflector.php @@ -51,7 +51,7 @@ public function __construct( public function asClass(): ClassReflector { - return new ClassReflector($this->definition); + return new ClassReflector($this->cleanDefinition); } public function equals(string|TypeReflector $type): bool diff --git a/src/Tempest/Reflection/tests/ReflectionTypeTest.php b/src/Tempest/Reflection/tests/ReflectionTypeTest.php index 83c60da21..b3c63dc17 100644 --- a/src/Tempest/Reflection/tests/ReflectionTypeTest.php +++ b/src/Tempest/Reflection/tests/ReflectionTypeTest.php @@ -39,4 +39,17 @@ public static function data(): Generator yield ['string', null, false]; yield ['?string', null, true]; } + + public function test_as_class(): void + { + $this->assertSame( + expected: A::class, + actual: (new TypeReflector('Tempest\Reflection\Tests\Fixtures\A'))->asClass()->getName(), + ); + + $this->assertSame( + expected: A::class, + actual: (new TypeReflector('?Tempest\Reflection\Tests\Fixtures\A'))->asClass()->getName(), + ); + } }