Skip to content

Commit a714c3c

Browse files
committed
Add more types
1 parent 05d224c commit a714c3c

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

src/Platform/StandardPlatform.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,39 @@ public function getTypes(Direction $direction): iterable
8787
// Adds support for the "T|U" union types
8888
yield new Builder\UnionTypeBuilder();
8989

90+
// Temporary aliases
91+
yield new Builder\TypeAliasBuilder('non-empty-string', $string, Reason::Deprecated);
92+
yield new Builder\TypeAliasBuilder('lowercase-string', $string, Reason::Deprecated);
93+
yield new Builder\TypeAliasBuilder('non-empty-lowercase-string', $string, Reason::Deprecated);
94+
yield new Builder\TypeAliasBuilder('uppercase-string', $string, Reason::Deprecated);
95+
yield new Builder\TypeAliasBuilder('non-empty-uppercase-string', $string, Reason::Deprecated);
96+
yield new Builder\TypeAliasBuilder('numeric-string', $string, Reason::Deprecated);
97+
yield new Builder\TypeAliasBuilder('literal-string', $string, Reason::Deprecated);
98+
yield new Builder\TypeAliasBuilder('non-empty-literal-string', $string, Reason::Deprecated);
99+
yield new Builder\TypeAliasBuilder('class-string', $string, Reason::Deprecated);
100+
yield new Builder\TypeAliasBuilder('interface-string', $string, Reason::Deprecated);
101+
yield new Builder\TypeAliasBuilder('trait-string', $string, Reason::Deprecated);
102+
yield new Builder\TypeAliasBuilder('enum-string', $string, Reason::Deprecated);
103+
yield new Builder\TypeAliasBuilder('callable-string', $string, Reason::Deprecated);
104+
yield new Builder\TypeAliasBuilder('truthy-string', $string, Reason::Deprecated);
105+
yield new Builder\TypeAliasBuilder('non-falsy-string', $string, Reason::Deprecated);
106+
107+
yield new Builder\TypeAliasBuilder('positive-int', $int, Reason::Deprecated);
108+
yield new Builder\TypeAliasBuilder('non-positive-int', $int, Reason::Deprecated);
109+
yield new Builder\TypeAliasBuilder('negative-int', $int, Reason::Deprecated);
110+
yield new Builder\TypeAliasBuilder('non-negative-int', $int, Reason::Deprecated);
111+
yield new Builder\TypeAliasBuilder('non-zero-int', $int, Reason::Deprecated);
112+
113+
yield new Builder\TypeAliasBuilder('number', $int, Reason::Deprecated);
114+
yield new Builder\TypeAliasBuilder('numeric', $int, Reason::Deprecated);
115+
116+
// Other
90117
if ($direction === Direction::Normalize) {
91118
// Adds support for the "iterable<T> -> list<T>" type
92119
yield new Builder\ListFromIterableTypeBuilder('list', 'mixed');
93120
// Adds support for the "object -> array{ ... }" type
94121
yield $object = new Builder\ObjectToArrayTypeBuilder('object');
122+
yield new Builder\TypeAliasBuilder(\stdClass::class, $object);
95123
// Adds support for the "BackedEnum -> scalar" type
96124
yield new Builder\BackedEnumToScalarTypeBuilder();
97125
// Adds support for the "UnitEnum -> scalar" type
@@ -105,6 +133,7 @@ public function getTypes(Direction $direction): iterable
105133
yield new Builder\ListFromArrayTypeBuilder('list', 'mixed');
106134
// Adds support for the "array{ ... } -> object" type
107135
yield $object = new Builder\ObjectFromArrayTypeBuilder('object');
136+
yield new Builder\TypeAliasBuilder(\stdClass::class, $object);
108137
// Adds support for the "scalar -> BackedEnum" type
109138
yield new Builder\BackedEnumFromScalarTypeBuilder();
110139
// Adds support for the "scalar -> UnitEnum" type
@@ -114,8 +143,6 @@ public function getTypes(Direction $direction): iterable
114143
// Adds support for the "array{ ... } -> object(ClassName)" type
115144
yield new Builder\ClassFromArrayTypeBuilder($this->meta);
116145
}
117-
118-
yield new Builder\TypeAliasBuilder(\stdClass::class, $object);
119146
}
120147

121148
public function getTypeCoercers(Direction $direction): iterable

tests/Platform/StandardPlatformTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,30 @@ final class StandardPlatformTest extends PlatformTestCase
4040
IntBackedEnumStub::class,
4141
// special
4242
'array-key',
43+
// special:string
4344
'numeric-string',
4445
'non-empty-string',
46+
'non-empty-lowercase-string',
47+
'non-empty-uppercase-string',
48+
'lowercase-string',
49+
'uppercase-string',
50+
'literal-string',
51+
'class-string',
52+
'interface-string',
53+
'trait-string',
54+
'enum-string',
55+
'callable-string',
56+
'truthy-string',
57+
'non-falsy-string',
58+
'non-empty-literal-string',
59+
// special:int
4560
'positive-int',
4661
'non-positive-int',
4762
'negative-int',
4863
'non-negative-int',
4964
'non-zero-int',
50-
'lowercase-string',
51-
'uppercase-string',
65+
'number',
66+
'numeric',
5267
// composite
5368
'?int',
5469
'int|false',

0 commit comments

Comments
 (0)