misc: add singleton usage of ClassStringType

This commit is contained in:
Romain Canon 2022-08-29 14:50:19 +02:00
parent ec494cec48
commit 4bc50e3e42
2 changed files with 6 additions and 0 deletions

View File

@ -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;

View File

@ -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();