Skip to content

Commit 99e5f2c

Browse files
committed
Fix
1 parent c5c325f commit 99e5f2c

1 file changed

Lines changed: 11 additions & 33 deletions

File tree

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPStan\Reflection\ReflectionProvider;
1515
use PHPStan\Type\ArrayType;
1616
use PHPStan\Type\MixedType;
17-
use PHPStan\Type\NeverType;
1817
use PHPStan\Type\ObjectType;
1918
use PHPStan\Type\ThisType;
2019
use PHPStan\Type\Type;
@@ -136,6 +135,15 @@ private function unionToSingleType(array $staticTypesByArgumentPosition, bool $r
136135
if ($staticTypeByArgumentPosition[$position]->isNull()->yes()) {
137136
$staticTypeByArgumentPosition[$position] = new MixedType();
138137
}
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+
}
139147
}
140148

141149
return $staticTypeByArgumentPosition;
@@ -224,43 +232,13 @@ private function isEmptyArray(Expr $expr): bool
224232
private function isArrayMixedMixedType(Type $type): bool
225233
{
226234
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-
257235
return false;
258236
}
259237

260-
if (! $type->getItemType() instanceof MixedType && ! $type->getItemType() instanceof NeverType) {
238+
if (! $type->getItemType() instanceof MixedType) {
261239
return false;
262240
}
263241

264-
return $type->getKeyType() instanceof MixedType || $type->getKeyType() instanceof NeverType;
242+
return $type->getKeyType() instanceof MixedType;
265243
}
266244
}

0 commit comments

Comments
 (0)