diff --git a/src/Type/Types/ClassStringType.php b/src/Type/Types/ClassStringType.php index 9b4db37..b592871 100644 --- a/src/Type/Types/ClassStringType.php +++ b/src/Type/Types/ClassStringType.php @@ -11,6 +11,7 @@ use CuyZ\Valinor\Type\Type; use CuyZ\Valinor\Type\Types\Exception\CannotCastValue; use CuyZ\Valinor\Type\Types\Exception\InvalidClassString; use CuyZ\Valinor\Type\Types\Exception\InvalidUnionOfClassString; +use CuyZ\Valinor\Utility\IsSingleton; use CuyZ\Valinor\Utility\Reflection\Reflection; use function is_object; @@ -20,6 +21,8 @@ use function method_exists; /** @internal */ final class ClassStringType implements StringType, CompositeType { + use IsSingleton; + /** @var ObjectType|UnionType|null */ private ?Type $subType; diff --git a/tests/Unit/Type/Types/ClassStringTypeTest.php b/tests/Unit/Type/Types/ClassStringTypeTest.php index 6b018f0..a5df6da 100644 --- a/tests/Unit/Type/Types/ClassStringTypeTest.php +++ b/tests/Unit/Type/Types/ClassStringTypeTest.php @@ -8,6 +8,7 @@ use CuyZ\Valinor\Tests\Fake\Type\FakeObjectCompositeType; use CuyZ\Valinor\Tests\Fake\Type\FakeObjectType; use CuyZ\Valinor\Tests\Fake\Type\FakeType; use CuyZ\Valinor\Tests\Fixture\Object\StringableObject; +use CuyZ\Valinor\Tests\Traits\TestIsSingleton; use CuyZ\Valinor\Type\Types\Exception\InvalidUnionOfClassString; use CuyZ\Valinor\Type\Types\NativeStringType; use CuyZ\Valinor\Type\Types\ClassStringType; @@ -24,6 +25,8 @@ use stdClass; final class ClassStringTypeTest extends TestCase { + use TestIsSingleton; + public function test_string_subtype_can_be_retrieved(): void { $subType = new FakeObjectType();