Skip to content

Commit a8c0d9c

Browse files
committed
fix
1 parent ef9e8aa commit a8c0d9c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Type/Php/ArrayKeyExistsFunctionTypeSpecifyingExtension.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ public function specifyTypes(
6666
&& !$keyType instanceof ConstantStringType
6767
) {
6868
if ($context->true()) {
69-
$specifiedTypes = $this->typeSpecifier->create(
70-
$array,
71-
new NonEmptyArrayType(),
72-
$context,
73-
$scope,
74-
);
69+
$specifiedTypes = new SpecifiedTypes();
70+
71+
if (count($keyType->getConstantScalarTypes()) <= 1) {
72+
$specifiedTypes = $specifiedTypes->unionWith($this->typeSpecifier->create(
73+
$array,
74+
new NonEmptyArrayType(),
75+
$context,
76+
$scope,
77+
));
78+
}
7579

7680
if ($arrayType->isIterableAtLeastOnce()->no()) {
7781
return $specifiedTypes;

0 commit comments

Comments
 (0)