Skip to content

Commit 89f5a54

Browse files
Simplify
1 parent d7d28b9 commit 89f5a54

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Type/Constant/ConstantArrayType.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,10 @@ public function unsetOffset(Type $offsetType): Type
742742
}
743743

744744
$newIsList = TrinaryLogic::createNo();
745-
if (!$this->isList->no()) {
745+
// We're unsetting something that might not be on the array,
746+
// so it might still be a list (with PHPStan definition)
747+
// because the nextAutoIndexes will not change.
748+
if (!$this->isList->no() && in_array($i, $this->optionalKeys, true)) {
746749
$preserveIsList = true;
747750
$isListOnlyIfKeysAreOptional = false;
748751
foreach ($newKeyTypes as $k2 => $newKeyType2) {
@@ -765,7 +768,7 @@ public function unsetOffset(Type $offsetType): Type
765768
}
766769

767770
if ($preserveIsList) {
768-
$newIsList = $this->isList;
771+
$newIsList = TrinaryLogic::createMaybe();
769772
}
770773
}
771774

0 commit comments

Comments
 (0)