|
11 | 11 | use PHPStan\Type\Constant\ConstantFloatType; |
12 | 12 | use PHPStan\Type\Constant\ConstantIntegerType; |
13 | 13 | use PHPStan\Type\Constant\ConstantStringType; |
| 14 | +use PHPStan\Type\Traits\ConstantScalarTypeTrait; |
14 | 15 | use PHPStan\Type\Traits\FalseyBooleanTypeTrait; |
15 | 16 | use PHPStan\Type\Traits\NonArrayTypeTrait; |
16 | 17 | use PHPStan\Type\Traits\NonCallableTypeTrait; |
|
23 | 24 | class NullType implements ConstantScalarType |
24 | 25 | { |
25 | 26 |
|
| 27 | + use ConstantScalarTypeTrait; |
26 | 28 | use NonArrayTypeTrait; |
27 | 29 | use NonCallableTypeTrait; |
28 | 30 | use NonIterableTypeTrait; |
@@ -72,73 +74,11 @@ public function generalize(GeneralizePrecision $precision): Type |
72 | 74 | return $this; |
73 | 75 | } |
74 | 76 |
|
75 | | - public function accepts(Type $type, bool $strictTypes): TrinaryLogic |
76 | | - { |
77 | | - return $this->acceptsWithReason($type, $strictTypes)->result; |
78 | | - } |
79 | | - |
80 | | - public function acceptsWithReason(Type $type, bool $strictTypes): AcceptsResult |
81 | | - { |
82 | | - if ($type instanceof self) { |
83 | | - return AcceptsResult::createYes(); |
84 | | - } |
85 | | - |
86 | | - if ($type instanceof CompoundType) { |
87 | | - return $type->isAcceptedWithReasonBy($this, $strictTypes); |
88 | | - } |
89 | | - |
90 | | - return AcceptsResult::createNo(); |
91 | | - } |
92 | | - |
93 | | - public function isSuperTypeOf(Type $type): TrinaryLogic |
94 | | - { |
95 | | - return $this->isSuperTypeOfWithReason($type)->result; |
96 | | - } |
97 | | - |
98 | | - public function isSuperTypeOfWithReason(Type $type): IsSuperTypeOfResult |
99 | | - { |
100 | | - if ($type instanceof self) { |
101 | | - return IsSuperTypeOfResult::createYes(); |
102 | | - } |
103 | | - |
104 | | - if ($type instanceof CompoundType) { |
105 | | - return $type->isSubTypeOfWithReason($this); |
106 | | - } |
107 | | - |
108 | | - return IsSuperTypeOfResult::createNo(); |
109 | | - } |
110 | | - |
111 | 77 | public function equals(Type $type): bool |
112 | 78 | { |
113 | 79 | return $type instanceof self; |
114 | 80 | } |
115 | 81 |
|
116 | | - public function isSmallerThan(Type $otherType): TrinaryLogic |
117 | | - { |
118 | | - if ($otherType instanceof ConstantScalarType) { |
119 | | - return TrinaryLogic::createFromBoolean(null < $otherType->getValue()); |
120 | | - } |
121 | | - |
122 | | - if ($otherType instanceof CompoundType) { |
123 | | - return $otherType->isGreaterThan($this); |
124 | | - } |
125 | | - |
126 | | - return TrinaryLogic::createMaybe(); |
127 | | - } |
128 | | - |
129 | | - public function isSmallerThanOrEqual(Type $otherType): TrinaryLogic |
130 | | - { |
131 | | - if ($otherType instanceof ConstantScalarType) { |
132 | | - return TrinaryLogic::createFromBoolean(null <= $otherType->getValue()); |
133 | | - } |
134 | | - |
135 | | - if ($otherType instanceof CompoundType) { |
136 | | - return $otherType->isGreaterThanOrEqual($this); |
137 | | - } |
138 | | - |
139 | | - return TrinaryLogic::createMaybe(); |
140 | | - } |
141 | | - |
142 | 82 | public function describe(VerbosityLevel $level): string |
143 | 83 | { |
144 | 84 | return 'null'; |
@@ -230,26 +170,6 @@ public function isNull(): TrinaryLogic |
230 | 170 | return TrinaryLogic::createYes(); |
231 | 171 | } |
232 | 172 |
|
233 | | - public function isConstantValue(): TrinaryLogic |
234 | | - { |
235 | | - return TrinaryLogic::createYes(); |
236 | | - } |
237 | | - |
238 | | - public function isConstantScalarValue(): TrinaryLogic |
239 | | - { |
240 | | - return TrinaryLogic::createYes(); |
241 | | - } |
242 | | - |
243 | | - public function getConstantScalarTypes(): array |
244 | | - { |
245 | | - return [$this]; |
246 | | - } |
247 | | - |
248 | | - public function getConstantScalarValues(): array |
249 | | - { |
250 | | - return [$this->getValue()]; |
251 | | - } |
252 | | - |
253 | 173 | public function isTrue(): TrinaryLogic |
254 | 174 | { |
255 | 175 | return TrinaryLogic::createNo(); |
|
0 commit comments