Skip to content

Commit 94071c3

Browse files
ainesophaurbrendt
andauthored
fix: type reflector uses wrong definition when converting to class (#592)
Co-authored-by: Brent Roose <[email protected]>
1 parent 9cca50d commit 94071c3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Tempest/Reflection/src/TypeReflector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151

5252
public function asClass(): ClassReflector
5353
{
54-
return new ClassReflector($this->definition);
54+
return new ClassReflector($this->cleanDefinition);
5555
}
5656

5757
public function equals(string|TypeReflector $type): bool

src/Tempest/Reflection/tests/ReflectionTypeTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,17 @@ public static function data(): Generator
3939
yield ['string', null, false];
4040
yield ['?string', null, true];
4141
}
42+
43+
public function test_as_class(): void
44+
{
45+
$this->assertSame(
46+
expected: A::class,
47+
actual: (new TypeReflector('Tempest\Reflection\Tests\Fixtures\A'))->asClass()->getName(),
48+
);
49+
50+
$this->assertSame(
51+
expected: A::class,
52+
actual: (new TypeReflector('?Tempest\Reflection\Tests\Fixtures\A'))->asClass()->getName(),
53+
);
54+
}
4255
}

0 commit comments

Comments
 (0)