Skip to content

Commit dd60a7c

Browse files
authored
[NodeTypeResolver] Apply logic Mixed inside Union check on TypeFactory::uniquateTypes() (#7346)
1 parent d945840 commit dd60a7c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/NodeTypeResolver/PHPStan/Type/TypeFactory.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ public function uniquateTypes(array $types, bool $keepConstant = false): array
6464
$hasFalse = false;
6565
$hasTrue = false;
6666
foreach ($types as $type) {
67+
// mixed only allowed to be standalone
6768
if ($type instanceof MixedType) {
68-
$type = new MixedType();
69+
/** @var array<TType> */
70+
return [new MixedType()];
6971
}
7072

7173
$type = $this->normalizeObjectType($totalTypes, $type);
@@ -168,12 +170,6 @@ private function createUnionOrSingleType(array $types): Type
168170
return $types[0];
169171
}
170172

171-
foreach ($types as $type) {
172-
if ($type instanceof MixedType) {
173-
return new MixedType();
174-
}
175-
}
176-
177173
return new UnionType($types);
178174
}
179175

0 commit comments

Comments
 (0)