|
14 | 14 | use PHPStan\Reflection\ReflectionProvider; |
15 | 15 | use PHPStan\Type\ArrayType; |
16 | 16 | use PHPStan\Type\MixedType; |
17 | | -use PHPStan\Type\NeverType; |
18 | 17 | use PHPStan\Type\ObjectType; |
19 | 18 | use PHPStan\Type\ThisType; |
20 | 19 | use PHPStan\Type\Type; |
@@ -136,6 +135,15 @@ private function unionToSingleType(array $staticTypesByArgumentPosition, bool $r |
136 | 135 | if ($staticTypeByArgumentPosition[$position]->isNull()->yes()) { |
137 | 136 | $staticTypeByArgumentPosition[$position] = new MixedType(); |
138 | 137 | } |
| 138 | + |
| 139 | + if ($staticTypeByArgumentPosition[$position] instanceof UnionType) { |
| 140 | + foreach ($staticTypeByArgumentPosition[$position]->getTypes() as $subType) { |
| 141 | + if ($subType instanceof MixedType) { |
| 142 | + $staticTypeByArgumentPosition[$position] = new MixedType(); |
| 143 | + continue 2; |
| 144 | + } |
| 145 | + } |
| 146 | + } |
139 | 147 | } |
140 | 148 |
|
141 | 149 | return $staticTypeByArgumentPosition; |
@@ -224,43 +232,13 @@ private function isEmptyArray(Expr $expr): bool |
224 | 232 | private function isArrayMixedMixedType(Type $type): bool |
225 | 233 | { |
226 | 234 | if (! $type instanceof ArrayType) { |
227 | | - if ($type instanceof UnionType) { |
228 | | - $types = $type->getTypes(); |
229 | | - $checkedType = $this->typeFactory->createMixedPassedOrUnionType($types); |
230 | | - |
231 | | - if ($checkedType instanceof UnionType) { |
232 | | - $types = $checkedType->getTypes(); |
233 | | - if (count($types) !== 2) { |
234 | | - return false; |
235 | | - } |
236 | | - |
237 | | - $hasMixedType = false; |
238 | | - $hasMixedArrayType = false; |
239 | | - |
240 | | - foreach ($types as $unionedType) { |
241 | | - if ($unionedType instanceof MixedType) { |
242 | | - $hasMixedType = true; |
243 | | - continue; |
244 | | - } |
245 | | - |
246 | | - if ($this->isArrayMixedMixedType($unionedType)) { |
247 | | - $hasMixedArrayType = true; |
248 | | - } |
249 | | - } |
250 | | - |
251 | | - if ($hasMixedType && $hasMixedArrayType) { |
252 | | - return true; |
253 | | - } |
254 | | - } |
255 | | - } |
256 | | - |
257 | 235 | return false; |
258 | 236 | } |
259 | 237 |
|
260 | | - if (! $type->getItemType() instanceof MixedType && ! $type->getItemType() instanceof NeverType) { |
| 238 | + if (! $type->getItemType() instanceof MixedType) { |
261 | 239 | return false; |
262 | 240 | } |
263 | 241 |
|
264 | | - return $type->getKeyType() instanceof MixedType || $type->getKeyType() instanceof NeverType; |
| 242 | + return $type->getKeyType() instanceof MixedType; |
265 | 243 | } |
266 | 244 | } |
0 commit comments