@@ -11,26 +11,26 @@ |
||
11 | 11 | |
12 | 12 | final class VoidType extends Type |
13 | 13 | { |
14 | - public function isAssignable(Type $other): bool |
|
15 | - { |
|
16 | - return $other instanceof self; |
|
17 | - } |
|
14 | + public function isAssignable(Type $other): bool |
|
15 | + { |
|
16 | + return $other instanceof self; |
|
17 | + } |
|
18 | 18 | |
19 | - public function name(): string |
|
20 | - { |
|
21 | - return 'void'; |
|
22 | - } |
|
19 | + public function name(): string |
|
20 | + { |
|
21 | + return 'void'; |
|
22 | + } |
|
23 | 23 | |
24 | - public function allowsNull(): bool |
|
25 | - { |
|
26 | - return false; |
|
27 | - } |
|
24 | + public function allowsNull(): bool |
|
25 | + { |
|
26 | + return false; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @psalm-assert-if-true VoidType $this |
|
31 | - */ |
|
32 | - public function isVoid(): bool |
|
33 | - { |
|
34 | - return true; |
|
35 | - } |
|
29 | + /** |
|
30 | + * @psalm-assert-if-true VoidType $this |
|
31 | + */ |
|
32 | + public function isVoid(): bool |
|
33 | + { |
|
34 | + return true; |
|
35 | + } |
|
36 | 36 | } |
@@ -11,31 +11,31 @@ |
||
11 | 11 | |
12 | 12 | final class NullType extends Type |
13 | 13 | { |
14 | - public function isAssignable(Type $other): bool |
|
15 | - { |
|
16 | - return !($other instanceof VoidType); |
|
17 | - } |
|
14 | + public function isAssignable(Type $other): bool |
|
15 | + { |
|
16 | + return !($other instanceof VoidType); |
|
17 | + } |
|
18 | 18 | |
19 | - public function name(): string |
|
20 | - { |
|
21 | - return 'null'; |
|
22 | - } |
|
19 | + public function name(): string |
|
20 | + { |
|
21 | + return 'null'; |
|
22 | + } |
|
23 | 23 | |
24 | - public function asString(): string |
|
25 | - { |
|
26 | - return 'null'; |
|
27 | - } |
|
24 | + public function asString(): string |
|
25 | + { |
|
26 | + return 'null'; |
|
27 | + } |
|
28 | 28 | |
29 | - public function allowsNull(): bool |
|
30 | - { |
|
31 | - return true; |
|
32 | - } |
|
29 | + public function allowsNull(): bool |
|
30 | + { |
|
31 | + return true; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @psalm-assert-if-true NullType $this |
|
36 | - */ |
|
37 | - public function isNull(): bool |
|
38 | - { |
|
39 | - return true; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @psalm-assert-if-true NullType $this |
|
36 | + */ |
|
37 | + public function isNull(): bool |
|
38 | + { |
|
39 | + return true; |
|
40 | + } |
|
41 | 41 | } |
@@ -11,32 +11,32 @@ |
||
11 | 11 | |
12 | 12 | final class TrueType extends Type |
13 | 13 | { |
14 | - public function isAssignable(Type $other): bool |
|
15 | - { |
|
16 | - if ($other instanceof self) { |
|
17 | - return true; |
|
18 | - } |
|
14 | + public function isAssignable(Type $other): bool |
|
15 | + { |
|
16 | + if ($other instanceof self) { |
|
17 | + return true; |
|
18 | + } |
|
19 | 19 | |
20 | - return $other instanceof SimpleType && |
|
21 | - $other->name() === 'bool' && |
|
22 | - $other->value() === true; |
|
23 | - } |
|
20 | + return $other instanceof SimpleType && |
|
21 | + $other->name() === 'bool' && |
|
22 | + $other->value() === true; |
|
23 | + } |
|
24 | 24 | |
25 | - public function name(): string |
|
26 | - { |
|
27 | - return 'true'; |
|
28 | - } |
|
25 | + public function name(): string |
|
26 | + { |
|
27 | + return 'true'; |
|
28 | + } |
|
29 | 29 | |
30 | - public function allowsNull(): bool |
|
31 | - { |
|
32 | - return false; |
|
33 | - } |
|
30 | + public function allowsNull(): bool |
|
31 | + { |
|
32 | + return false; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @psalm-assert-if-true TrueType $this |
|
37 | - */ |
|
38 | - public function isTrue(): bool |
|
39 | - { |
|
40 | - return true; |
|
41 | - } |
|
35 | + /** |
|
36 | + * @psalm-assert-if-true TrueType $this |
|
37 | + */ |
|
38 | + public function isTrue(): bool |
|
39 | + { |
|
40 | + return true; |
|
41 | + } |
|
42 | 42 | } |
@@ -11,44 +11,44 @@ |
||
11 | 11 | |
12 | 12 | final class GenericObjectType extends Type |
13 | 13 | { |
14 | - /** |
|
15 | - * @var bool |
|
16 | - */ |
|
17 | - private $allowsNull; |
|
18 | - |
|
19 | - public function __construct(bool $nullable) |
|
20 | - { |
|
21 | - $this->allowsNull = $nullable; |
|
22 | - } |
|
23 | - |
|
24 | - public function isAssignable(Type $other): bool |
|
25 | - { |
|
26 | - if ($this->allowsNull && $other instanceof NullType) { |
|
27 | - return true; |
|
28 | - } |
|
29 | - |
|
30 | - if (!$other instanceof ObjectType) { |
|
31 | - return false; |
|
32 | - } |
|
33 | - |
|
34 | - return true; |
|
35 | - } |
|
36 | - |
|
37 | - public function name(): string |
|
38 | - { |
|
39 | - return 'object'; |
|
40 | - } |
|
41 | - |
|
42 | - public function allowsNull(): bool |
|
43 | - { |
|
44 | - return $this->allowsNull; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @psalm-assert-if-true GenericObjectType $this |
|
49 | - */ |
|
50 | - public function isGenericObject(): bool |
|
51 | - { |
|
52 | - return true; |
|
53 | - } |
|
14 | + /** |
|
15 | + * @var bool |
|
16 | + */ |
|
17 | + private $allowsNull; |
|
18 | + |
|
19 | + public function __construct(bool $nullable) |
|
20 | + { |
|
21 | + $this->allowsNull = $nullable; |
|
22 | + } |
|
23 | + |
|
24 | + public function isAssignable(Type $other): bool |
|
25 | + { |
|
26 | + if ($this->allowsNull && $other instanceof NullType) { |
|
27 | + return true; |
|
28 | + } |
|
29 | + |
|
30 | + if (!$other instanceof ObjectType) { |
|
31 | + return false; |
|
32 | + } |
|
33 | + |
|
34 | + return true; |
|
35 | + } |
|
36 | + |
|
37 | + public function name(): string |
|
38 | + { |
|
39 | + return 'object'; |
|
40 | + } |
|
41 | + |
|
42 | + public function allowsNull(): bool |
|
43 | + { |
|
44 | + return $this->allowsNull; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * @psalm-assert-if-true GenericObjectType $this |
|
49 | + */ |
|
50 | + public function isGenericObject(): bool |
|
51 | + { |
|
52 | + return true; |
|
53 | + } |
|
54 | 54 | } |
@@ -15,124 +15,124 @@ |
||
15 | 15 | |
16 | 16 | final class UnionType extends Type |
17 | 17 | { |
18 | - /** |
|
19 | - * @psalm-var non-empty-list<Type> |
|
20 | - */ |
|
21 | - private $types; |
|
22 | - |
|
23 | - /** |
|
24 | - * @throws RuntimeException |
|
25 | - */ |
|
26 | - public function __construct(Type ...$types) |
|
27 | - { |
|
28 | - $this->ensureMinimumOfTwoTypes(...$types); |
|
29 | - $this->ensureOnlyValidTypes(...$types); |
|
30 | - |
|
31 | - $this->types = $types; |
|
32 | - } |
|
33 | - |
|
34 | - public function isAssignable(Type $other): bool |
|
35 | - { |
|
36 | - foreach ($this->types as $type) { |
|
37 | - if ($type->isAssignable($other)) { |
|
38 | - return true; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - return false; |
|
43 | - } |
|
44 | - |
|
45 | - public function asString(): string |
|
46 | - { |
|
47 | - return $this->name(); |
|
48 | - } |
|
49 | - |
|
50 | - public function name(): string |
|
51 | - { |
|
52 | - $types = []; |
|
53 | - |
|
54 | - foreach ($this->types as $type) { |
|
55 | - if ($type->isIntersection()) { |
|
56 | - $types[] = '(' . $type->name() . ')'; |
|
57 | - |
|
58 | - continue; |
|
59 | - } |
|
60 | - |
|
61 | - $types[] = $type->name(); |
|
62 | - } |
|
63 | - |
|
64 | - sort($types); |
|
65 | - |
|
66 | - return implode('|', $types); |
|
67 | - } |
|
68 | - |
|
69 | - public function allowsNull(): bool |
|
70 | - { |
|
71 | - foreach ($this->types as $type) { |
|
72 | - if ($type instanceof NullType) { |
|
73 | - return true; |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - return false; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @psalm-assert-if-true UnionType $this |
|
82 | - */ |
|
83 | - public function isUnion(): bool |
|
84 | - { |
|
85 | - return true; |
|
86 | - } |
|
87 | - |
|
88 | - public function containsIntersectionTypes(): bool |
|
89 | - { |
|
90 | - foreach ($this->types as $type) { |
|
91 | - if ($type->isIntersection()) { |
|
92 | - return true; |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - return false; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @psalm-return non-empty-list<Type> |
|
101 | - */ |
|
102 | - public function types(): array |
|
103 | - { |
|
104 | - return $this->types; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @throws RuntimeException |
|
109 | - */ |
|
110 | - private function ensureMinimumOfTwoTypes(Type ...$types): void |
|
111 | - { |
|
112 | - if (count($types) < 2) { |
|
113 | - throw new RuntimeException( |
|
114 | - 'A union type must be composed of at least two types' |
|
115 | - ); |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @throws RuntimeException |
|
121 | - */ |
|
122 | - private function ensureOnlyValidTypes(Type ...$types): void |
|
123 | - { |
|
124 | - foreach ($types as $type) { |
|
125 | - if ($type instanceof UnknownType) { |
|
126 | - throw new RuntimeException( |
|
127 | - 'A union type must not be composed of an unknown type' |
|
128 | - ); |
|
129 | - } |
|
130 | - |
|
131 | - if ($type instanceof VoidType) { |
|
132 | - throw new RuntimeException( |
|
133 | - 'A union type must not be composed of a void type' |
|
134 | - ); |
|
135 | - } |
|
136 | - } |
|
137 | - } |
|
18 | + /** |
|
19 | + * @psalm-var non-empty-list<Type> |
|
20 | + */ |
|
21 | + private $types; |
|
22 | + |
|
23 | + /** |
|
24 | + * @throws RuntimeException |
|
25 | + */ |
|
26 | + public function __construct(Type ...$types) |
|
27 | + { |
|
28 | + $this->ensureMinimumOfTwoTypes(...$types); |
|
29 | + $this->ensureOnlyValidTypes(...$types); |
|
30 | + |
|
31 | + $this->types = $types; |
|
32 | + } |
|
33 | + |
|
34 | + public function isAssignable(Type $other): bool |
|
35 | + { |
|
36 | + foreach ($this->types as $type) { |
|
37 | + if ($type->isAssignable($other)) { |
|
38 | + return true; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + return false; |
|
43 | + } |
|
44 | + |
|
45 | + public function asString(): string |
|
46 | + { |
|
47 | + return $this->name(); |
|
48 | + } |
|
49 | + |
|
50 | + public function name(): string |
|
51 | + { |
|
52 | + $types = []; |
|
53 | + |
|
54 | + foreach ($this->types as $type) { |
|
55 | + if ($type->isIntersection()) { |
|
56 | + $types[] = '(' . $type->name() . ')'; |
|
57 | + |
|
58 | + continue; |
|
59 | + } |
|
60 | + |
|
61 | + $types[] = $type->name(); |
|
62 | + } |
|
63 | + |
|
64 | + sort($types); |
|
65 | + |
|
66 | + return implode('|', $types); |
|
67 | + } |
|
68 | + |
|
69 | + public function allowsNull(): bool |
|
70 | + { |
|
71 | + foreach ($this->types as $type) { |
|
72 | + if ($type instanceof NullType) { |
|
73 | + return true; |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + return false; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @psalm-assert-if-true UnionType $this |
|
82 | + */ |
|
83 | + public function isUnion(): bool |
|
84 | + { |
|
85 | + return true; |
|
86 | + } |
|
87 | + |
|
88 | + public function containsIntersectionTypes(): bool |
|
89 | + { |
|
90 | + foreach ($this->types as $type) { |
|
91 | + if ($type->isIntersection()) { |
|
92 | + return true; |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + return false; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @psalm-return non-empty-list<Type> |
|
101 | + */ |
|
102 | + public function types(): array |
|
103 | + { |
|
104 | + return $this->types; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @throws RuntimeException |
|
109 | + */ |
|
110 | + private function ensureMinimumOfTwoTypes(Type ...$types): void |
|
111 | + { |
|
112 | + if (count($types) < 2) { |
|
113 | + throw new RuntimeException( |
|
114 | + 'A union type must be composed of at least two types' |
|
115 | + ); |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @throws RuntimeException |
|
121 | + */ |
|
122 | + private function ensureOnlyValidTypes(Type ...$types): void |
|
123 | + { |
|
124 | + foreach ($types as $type) { |
|
125 | + if ($type instanceof UnknownType) { |
|
126 | + throw new RuntimeException( |
|
127 | + 'A union type must not be composed of an unknown type' |
|
128 | + ); |
|
129 | + } |
|
130 | + |
|
131 | + if ($type instanceof VoidType) { |
|
132 | + throw new RuntimeException( |
|
133 | + 'A union type must not be composed of a void type' |
|
134 | + ); |
|
135 | + } |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | |
54 | 54 | foreach ($this->types as $type) { |
55 | 55 | if ($type->isIntersection()) { |
56 | - $types[] = '(' . $type->name() . ')'; |
|
56 | + $types[] = '('.$type->name().')'; |
|
57 | 57 | |
58 | 58 | continue; |
59 | 59 | } |
@@ -17,110 +17,110 @@ |
||
17 | 17 | |
18 | 18 | final class IntersectionType extends Type |
19 | 19 | { |
20 | - /** |
|
21 | - * @psalm-var non-empty-list<Type> |
|
22 | - */ |
|
23 | - private $types; |
|
24 | - |
|
25 | - /** |
|
26 | - * @throws RuntimeException |
|
27 | - */ |
|
28 | - public function __construct(Type ...$types) |
|
29 | - { |
|
30 | - $this->ensureMinimumOfTwoTypes(...$types); |
|
31 | - $this->ensureOnlyValidTypes(...$types); |
|
32 | - $this->ensureNoDuplicateTypes(...$types); |
|
33 | - |
|
34 | - $this->types = $types; |
|
35 | - } |
|
36 | - |
|
37 | - public function isAssignable(Type $other): bool |
|
38 | - { |
|
39 | - return $other->isObject(); |
|
40 | - } |
|
41 | - |
|
42 | - public function asString(): string |
|
43 | - { |
|
44 | - return $this->name(); |
|
45 | - } |
|
46 | - |
|
47 | - public function name(): string |
|
48 | - { |
|
49 | - $types = []; |
|
50 | - |
|
51 | - foreach ($this->types as $type) { |
|
52 | - $types[] = $type->name(); |
|
53 | - } |
|
54 | - |
|
55 | - sort($types); |
|
56 | - |
|
57 | - return implode('&', $types); |
|
58 | - } |
|
59 | - |
|
60 | - public function allowsNull(): bool |
|
61 | - { |
|
62 | - return false; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @psalm-assert-if-true IntersectionType $this |
|
67 | - */ |
|
68 | - public function isIntersection(): bool |
|
69 | - { |
|
70 | - return true; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @psalm-return non-empty-list<Type> |
|
75 | - */ |
|
76 | - public function types(): array |
|
77 | - { |
|
78 | - return $this->types; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @throws RuntimeException |
|
83 | - */ |
|
84 | - private function ensureMinimumOfTwoTypes(Type ...$types): void |
|
85 | - { |
|
86 | - if (count($types) < 2) { |
|
87 | - throw new RuntimeException( |
|
88 | - 'An intersection type must be composed of at least two types' |
|
89 | - ); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @throws RuntimeException |
|
95 | - */ |
|
96 | - private function ensureOnlyValidTypes(Type ...$types): void |
|
97 | - { |
|
98 | - foreach ($types as $type) { |
|
99 | - if (!$type->isObject()) { |
|
100 | - throw new RuntimeException( |
|
101 | - 'An intersection type can only be composed of interfaces and classes' |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @throws RuntimeException |
|
109 | - */ |
|
110 | - private function ensureNoDuplicateTypes(Type ...$types): void |
|
111 | - { |
|
112 | - $names = []; |
|
113 | - |
|
114 | - foreach ($types as $type) { |
|
115 | - assert($type instanceof ObjectType); |
|
116 | - |
|
117 | - $names[] = $type->className()->qualifiedName(); |
|
118 | - } |
|
119 | - |
|
120 | - if (count(array_unique($names)) < count($names)) { |
|
121 | - throw new RuntimeException( |
|
122 | - 'An intersection type must not contain duplicate types' |
|
123 | - ); |
|
124 | - } |
|
125 | - } |
|
20 | + /** |
|
21 | + * @psalm-var non-empty-list<Type> |
|
22 | + */ |
|
23 | + private $types; |
|
24 | + |
|
25 | + /** |
|
26 | + * @throws RuntimeException |
|
27 | + */ |
|
28 | + public function __construct(Type ...$types) |
|
29 | + { |
|
30 | + $this->ensureMinimumOfTwoTypes(...$types); |
|
31 | + $this->ensureOnlyValidTypes(...$types); |
|
32 | + $this->ensureNoDuplicateTypes(...$types); |
|
33 | + |
|
34 | + $this->types = $types; |
|
35 | + } |
|
36 | + |
|
37 | + public function isAssignable(Type $other): bool |
|
38 | + { |
|
39 | + return $other->isObject(); |
|
40 | + } |
|
41 | + |
|
42 | + public function asString(): string |
|
43 | + { |
|
44 | + return $this->name(); |
|
45 | + } |
|
46 | + |
|
47 | + public function name(): string |
|
48 | + { |
|
49 | + $types = []; |
|
50 | + |
|
51 | + foreach ($this->types as $type) { |
|
52 | + $types[] = $type->name(); |
|
53 | + } |
|
54 | + |
|
55 | + sort($types); |
|
56 | + |
|
57 | + return implode('&', $types); |
|
58 | + } |
|
59 | + |
|
60 | + public function allowsNull(): bool |
|
61 | + { |
|
62 | + return false; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @psalm-assert-if-true IntersectionType $this |
|
67 | + */ |
|
68 | + public function isIntersection(): bool |
|
69 | + { |
|
70 | + return true; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @psalm-return non-empty-list<Type> |
|
75 | + */ |
|
76 | + public function types(): array |
|
77 | + { |
|
78 | + return $this->types; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @throws RuntimeException |
|
83 | + */ |
|
84 | + private function ensureMinimumOfTwoTypes(Type ...$types): void |
|
85 | + { |
|
86 | + if (count($types) < 2) { |
|
87 | + throw new RuntimeException( |
|
88 | + 'An intersection type must be composed of at least two types' |
|
89 | + ); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @throws RuntimeException |
|
95 | + */ |
|
96 | + private function ensureOnlyValidTypes(Type ...$types): void |
|
97 | + { |
|
98 | + foreach ($types as $type) { |
|
99 | + if (!$type->isObject()) { |
|
100 | + throw new RuntimeException( |
|
101 | + 'An intersection type can only be composed of interfaces and classes' |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @throws RuntimeException |
|
109 | + */ |
|
110 | + private function ensureNoDuplicateTypes(Type ...$types): void |
|
111 | + { |
|
112 | + $names = []; |
|
113 | + |
|
114 | + foreach ($types as $type) { |
|
115 | + assert($type instanceof ObjectType); |
|
116 | + |
|
117 | + $names[] = $type->className()->qualifiedName(); |
|
118 | + } |
|
119 | + |
|
120 | + if (count(array_unique($names)) < count($names)) { |
|
121 | + throw new RuntimeException( |
|
122 | + 'An intersection type must not contain duplicate types' |
|
123 | + ); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |
@@ -11,32 +11,32 @@ |
||
11 | 11 | |
12 | 12 | final class FalseType extends Type |
13 | 13 | { |
14 | - public function isAssignable(Type $other): bool |
|
15 | - { |
|
16 | - if ($other instanceof self) { |
|
17 | - return true; |
|
18 | - } |
|
14 | + public function isAssignable(Type $other): bool |
|
15 | + { |
|
16 | + if ($other instanceof self) { |
|
17 | + return true; |
|
18 | + } |
|
19 | 19 | |
20 | - return $other instanceof SimpleType && |
|
21 | - $other->name() === 'bool' && |
|
22 | - $other->value() === false; |
|
23 | - } |
|
20 | + return $other instanceof SimpleType && |
|
21 | + $other->name() === 'bool' && |
|
22 | + $other->value() === false; |
|
23 | + } |
|
24 | 24 | |
25 | - public function name(): string |
|
26 | - { |
|
27 | - return 'false'; |
|
28 | - } |
|
25 | + public function name(): string |
|
26 | + { |
|
27 | + return 'false'; |
|
28 | + } |
|
29 | 29 | |
30 | - public function allowsNull(): bool |
|
31 | - { |
|
32 | - return false; |
|
33 | - } |
|
30 | + public function allowsNull(): bool |
|
31 | + { |
|
32 | + return false; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @psalm-assert-if-true FalseType $this |
|
37 | - */ |
|
38 | - public function isFalse(): bool |
|
39 | - { |
|
40 | - return true; |
|
41 | - } |
|
35 | + /** |
|
36 | + * @psalm-assert-if-true FalseType $this |
|
37 | + */ |
|
38 | + public function isFalse(): bool |
|
39 | + { |
|
40 | + return true; |
|
41 | + } |
|
42 | 42 | } |
@@ -11,26 +11,26 @@ |
||
11 | 11 | |
12 | 12 | final class NeverType extends Type |
13 | 13 | { |
14 | - public function isAssignable(Type $other): bool |
|
15 | - { |
|
16 | - return $other instanceof self; |
|
17 | - } |
|
14 | + public function isAssignable(Type $other): bool |
|
15 | + { |
|
16 | + return $other instanceof self; |
|
17 | + } |
|
18 | 18 | |
19 | - public function name(): string |
|
20 | - { |
|
21 | - return 'never'; |
|
22 | - } |
|
19 | + public function name(): string |
|
20 | + { |
|
21 | + return 'never'; |
|
22 | + } |
|
23 | 23 | |
24 | - public function allowsNull(): bool |
|
25 | - { |
|
26 | - return false; |
|
27 | - } |
|
24 | + public function allowsNull(): bool |
|
25 | + { |
|
26 | + return false; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @psalm-assert-if-true NeverType $this |
|
31 | - */ |
|
32 | - public function isNever(): bool |
|
33 | - { |
|
34 | - return true; |
|
35 | - } |
|
29 | + /** |
|
30 | + * @psalm-assert-if-true NeverType $this |
|
31 | + */ |
|
32 | + public function isNever(): bool |
|
33 | + { |
|
34 | + return true; |
|
35 | + } |
|
36 | 36 | } |
@@ -11,58 +11,58 @@ |
||
11 | 11 | |
12 | 12 | final class StaticType extends Type |
13 | 13 | { |
14 | - /** |
|
15 | - * @var TypeName |
|
16 | - */ |
|
17 | - private $className; |
|
14 | + /** |
|
15 | + * @var TypeName |
|
16 | + */ |
|
17 | + private $className; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var bool |
|
21 | - */ |
|
22 | - private $allowsNull; |
|
19 | + /** |
|
20 | + * @var bool |
|
21 | + */ |
|
22 | + private $allowsNull; |
|
23 | 23 | |
24 | - public function __construct(TypeName $className, bool $allowsNull) |
|
25 | - { |
|
26 | - $this->className = $className; |
|
27 | - $this->allowsNull = $allowsNull; |
|
28 | - } |
|
24 | + public function __construct(TypeName $className, bool $allowsNull) |
|
25 | + { |
|
26 | + $this->className = $className; |
|
27 | + $this->allowsNull = $allowsNull; |
|
28 | + } |
|
29 | 29 | |
30 | - public function isAssignable(Type $other): bool |
|
31 | - { |
|
32 | - if ($this->allowsNull && $other instanceof NullType) { |
|
33 | - return true; |
|
34 | - } |
|
30 | + public function isAssignable(Type $other): bool |
|
31 | + { |
|
32 | + if ($this->allowsNull && $other instanceof NullType) { |
|
33 | + return true; |
|
34 | + } |
|
35 | 35 | |
36 | - if (!$other instanceof ObjectType) { |
|
37 | - return false; |
|
38 | - } |
|
36 | + if (!$other instanceof ObjectType) { |
|
37 | + return false; |
|
38 | + } |
|
39 | 39 | |
40 | - if (0 === strcasecmp($this->className->qualifiedName(), $other->className()->qualifiedName())) { |
|
41 | - return true; |
|
42 | - } |
|
40 | + if (0 === strcasecmp($this->className->qualifiedName(), $other->className()->qualifiedName())) { |
|
41 | + return true; |
|
42 | + } |
|
43 | 43 | |
44 | - if (is_subclass_of($other->className()->qualifiedName(), $this->className->qualifiedName(), true)) { |
|
45 | - return true; |
|
46 | - } |
|
44 | + if (is_subclass_of($other->className()->qualifiedName(), $this->className->qualifiedName(), true)) { |
|
45 | + return true; |
|
46 | + } |
|
47 | 47 | |
48 | - return false; |
|
49 | - } |
|
48 | + return false; |
|
49 | + } |
|
50 | 50 | |
51 | - public function name(): string |
|
52 | - { |
|
53 | - return 'static'; |
|
54 | - } |
|
51 | + public function name(): string |
|
52 | + { |
|
53 | + return 'static'; |
|
54 | + } |
|
55 | 55 | |
56 | - public function allowsNull(): bool |
|
57 | - { |
|
58 | - return $this->allowsNull; |
|
59 | - } |
|
56 | + public function allowsNull(): bool |
|
57 | + { |
|
58 | + return $this->allowsNull; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @psalm-assert-if-true StaticType $this |
|
63 | - */ |
|
64 | - public function isStatic(): bool |
|
65 | - { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @psalm-assert-if-true StaticType $this |
|
63 | + */ |
|
64 | + public function isStatic(): bool |
|
65 | + { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | } |