Skip to content

Commit 9bf14f9

Browse files
authored
[TypeDeclarationDocblock] clean up recursive mixed check, only in first union to avoid deep mixed removed (#7341)
1 parent df78547 commit 9bf14f9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,16 @@ private function unionToSingleType(array $staticTypesByArgumentPosition, bool $r
134134

135135
if ($staticTypeByArgumentPosition[$position] instanceof UnionType) {
136136
foreach ($staticTypeByArgumentPosition[$position]->getTypes() as $subType) {
137+
// has another type over mixed is not allowed, even on native type
137138
if ($subType instanceof MixedType) {
138139
$staticTypeByArgumentPosition[$position] = new MixedType();
139140
continue 2;
140141
}
142+
143+
if ($removeMixedArray && $subType instanceof ArrayType && $this->isArrayMixedMixedType($subType)) {
144+
$staticTypeByArgumentPosition[$position] = new MixedType();
145+
continue 2;
146+
}
141147
}
142148
}
143149
}
@@ -228,14 +234,6 @@ private function isEmptyArray(Expr $expr): bool
228234
private function isArrayMixedMixedType(Type $type): bool
229235
{
230236
if (! $type instanceof ArrayType) {
231-
if ($type instanceof UnionType) {
232-
foreach ($type->getTypes() as $subType) {
233-
if ($subType instanceof ArrayType && $this->isArrayMixedMixedType($subType)) {
234-
return true;
235-
}
236-
}
237-
}
238-
239237
return false;
240238
}
241239

0 commit comments

Comments
 (0)