|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Spatie\Typed; |
|
6
|
|
|
|
|
7
|
|
|
use Spatie\Typed\Types\Type; |
|
8
|
|
|
use Spatie\Typed\Types\ArrayType; |
|
9
|
|
|
use Spatie\Typed\Types\FloatType; |
|
10
|
|
|
use Spatie\Typed\Types\StringType; |
|
11
|
|
|
use Spatie\Typed\Types\BooleanType; |
|
12
|
|
|
use Spatie\Typed\Types\GenericType; |
|
13
|
|
|
use Spatie\Typed\Types\IntegerType; |
|
14
|
|
|
use Spatie\Typed\Types\CallableType; |
|
15
|
|
|
use Spatie\Typed\Types\NullableType; |
|
16
|
|
|
use Spatie\Typed\Types\CollectionType; |
|
17
|
|
|
|
|
18
|
|
|
class T |
|
19
|
|
|
{ |
|
20
|
|
|
public static function array(): ArrayType |
|
21
|
|
|
{ |
|
22
|
|
|
return new ArrayType(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public static function bool(): BooleanType |
|
26
|
|
|
{ |
|
27
|
|
|
return new BooleanType(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public static function boolean(): BooleanType |
|
31
|
|
|
{ |
|
32
|
|
|
return new BooleanType(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public static function callable(): CallableType |
|
36
|
|
|
{ |
|
37
|
|
|
return new CallableType(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public static function collection(): CollectionType |
|
41
|
|
|
{ |
|
42
|
|
|
return new CollectionType(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public static function float(): FloatType |
|
46
|
|
|
{ |
|
47
|
|
|
return new FloatType(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public static function double(): FloatType |
|
51
|
|
|
{ |
|
52
|
|
|
return new FloatType(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function generic(string $type): GenericType |
|
56
|
|
|
{ |
|
57
|
|
|
return new GenericType($type); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public static function int(): IntegerType |
|
61
|
|
|
{ |
|
62
|
|
|
return new IntegerType(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public static function integer(): IntegerType |
|
66
|
|
|
{ |
|
67
|
|
|
return new IntegerType(); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public static function string(): StringType |
|
71
|
|
|
{ |
|
72
|
|
|
return new StringType(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public static function nullable(Type $type): NullableType |
|
76
|
|
|
{ |
|
77
|
|
|
return new NullableType($type); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|