diff --git a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php index 8e71843aafb..f0864011f8e 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php +++ b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php @@ -134,10 +134,16 @@ private function unionToSingleType(array $staticTypesByArgumentPosition, bool $r if ($staticTypeByArgumentPosition[$position] instanceof UnionType) { foreach ($staticTypeByArgumentPosition[$position]->getTypes() as $subType) { + // has another type over mixed is not allowed, even on native type if ($subType instanceof MixedType) { $staticTypeByArgumentPosition[$position] = new MixedType(); continue 2; } + + if ($removeMixedArray && $subType instanceof ArrayType && $this->isArrayMixedMixedType($subType)) { + $staticTypeByArgumentPosition[$position] = new MixedType(); + continue 2; + } } } } @@ -228,14 +234,6 @@ private function isEmptyArray(Expr $expr): bool private function isArrayMixedMixedType(Type $type): bool { if (! $type instanceof ArrayType) { - if ($type instanceof UnionType) { - foreach ($type->getTypes() as $subType) { - if ($subType instanceof ArrayType && $this->isArrayMixedMixedType($subType)) { - return true; - } - } - } - return false; }